Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: unbounded recursive call in a shell script crashes zsh
- X-seq: zsh-workers 40958
- From: Kamil Dudka <kdudka@xxxxxxxxxx>
- To: Jérémie Roquet <jroquet@xxxxxxxxxxxxx>
- Subject: Re: unbounded recursive call in a shell script crashes zsh
- Date: Tue, 11 Apr 2017 16:38:31 +0200
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kdudka@xxxxxxxxxx
- Cc: Zsh Hackers' List <zsh-workers@xxxxxxx>
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 03FC3C059725
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 03FC3C059725
- In-reply-to: <CAFOazAM_2dX4F-5i5ER61EFf8WmO-43CnNbJq3CZWQHdaG78=A@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <2960832.nVDpiBkaWZ@kdudka-nb> <CAFOazAOTiUu8w9ZHZnhpBBtQ5FHj-Jb1OLxGf6eO4S-9DS7=fQ@mail.gmail.com> <CAFOazAM_2dX4F-5i5ER61EFf8WmO-43CnNbJq3CZWQHdaG78=A@mail.gmail.com>
On Tuesday, April 11, 2017 16:01:10 Jérémie Roquet wrote:
> 2017-04-11 15:29 GMT+02:00 Jérémie Roquet <jroquet@xxxxxxxxxxxxx>:
> > 2017-04-11 15:00 GMT+02:00 Kamil Dudka <kdudka@xxxxxxxxxx>:
> >> The following shell script crashes zsh (tested with zsh-5.3.1-90-
g63f086d):
> >> function foo() {
> >>
> >> if true; then
> >>
> >> foo
> >>
> >> fi
> >>
> >> }
> >>
> >> foo
> >
> > That's interesting:
> >
> > $ zsh -c 'foo() { foo }; foo'
> > foo: maximum nested function level reached
> >
> > $ zsh -c 'foo() { if true; then foo; fi }; foo'
> > Segmentation fault
>
> That looks like a stack overflow…
>
> Doing either of the following fixed the issue for me:
> - recompile after “./configure --enable-max-function-depth=500”
> (default is 1000);
> - execute after “ulimit -s 16384” (default for me was 8192).
Thanks! I can confirm that the error is handled properly after increasing
the limit for stack allocation.
So the difference is caused by the fact that recent versions of zsh are
more hungry on stack, so the stack allocation limit is exceeded before the
shell call recursion limit is reached.
Kamil
> Best regards,
Messages sorted by:
Reverse Date,
Date,
Thread,
Author