From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: unbounded recursive call in a shell script crashes zsh
Date: Sun, 16 Apr 2017 23:12:18 +0000 [thread overview]
Message-ID: <20170416231218.GA28022@fujitsu.shahaf.local2> (raw)
In-Reply-To: <170416140016.ZM21368@torch.brasslantern.com>
Bart Schaefer wrote on Sun, Apr 16, 2017 at 14:00:16 -0700:
> On Apr 16, 6:56pm, Daniel Shahaf wrote:
> }
> } Hmm. Would it work to measure the stack space used, by declaring
> } a local variable in main() [...]?
>
> Aside from it depending on a particular stack architecture which may
> not be shared by all hardware, it doesn't solve the problem of knowing
> how much stack space will be occupied by the average call frame.
>
> And even if you could manage to divide the available space by the
> average size, that's still not a guarantee you won't run out if a
> number of frames are larger than average.
I originally thought of average inter-frame step size too, but then
I realized that the code could compare how far it is from main() to
RLIMIT_STACK and bail out gracefully if it has, say, less than X KB or
Y% of stack remaining.
But as you say, that's unportable. (Not undefined behaviour; just not
guaranteed to be correct.) Also it really shouldn't be an
application-level concern...
next prev parent reply other threads:[~2017-04-16 23:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-11 13:00 Kamil Dudka
2017-04-11 13:29 ` Jérémie Roquet
2017-04-11 14:01 ` Jérémie Roquet
2017-04-11 14:38 ` Kamil Dudka
2017-04-12 2:12 ` Bart Schaefer
2017-04-12 7:30 ` Kamil Dudka
2017-04-12 22:11 ` Bart Schaefer
2017-04-13 14:30 ` Kamil Dudka
2017-04-13 15:21 ` Jérémie Roquet
2017-04-13 16:01 ` Jérémie Roquet
2017-04-15 16:14 ` Bart Schaefer
2017-04-16 18:56 ` Daniel Shahaf
2017-04-16 21:00 ` Bart Schaefer
2017-04-16 23:12 ` Daniel Shahaf [this message]
2017-04-17 0:17 ` Bart Schaefer
2017-04-18 13:54 ` Kamil Dudka
2017-04-19 21:01 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170416231218.GA28022@fujitsu.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).