From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6193 invoked by alias); 11 Apr 2017 14:38:29 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40958 Received: (qmail 3731 invoked from network); 11 Apr 2017 14:38:29 -0000 X-Qmail-Scanner-Diagnostics: from mx1.redhat.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.132.183.28):SA:0(-5.0/5.0):. Processed in 1.574134 secs); 11 Apr 2017 14:38:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: kdudka@redhat.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 03FC3C059725 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@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 03FC3C059725 From: Kamil Dudka To: =?ISO-8859-1?Q?J=E9r=E9mie?= Roquet Cc: Zsh Hackers' List Subject: Re: unbounded recursive call in a shell script crashes zsh Date: Tue, 11 Apr 2017 16:38:31 +0200 Message-ID: <1569411.Kln6y2GJnM@kdudka-nb> User-Agent: KMail/4.14.10 (Linux/4.9.16-gentoo; KDE/4.14.29; x86_64; ; ) In-Reply-To: References: <2960832.nVDpiBkaWZ@kdudka-nb> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 11 Apr 2017 14:38:24 +0000 (UTC) On Tuesday, April 11, 2017 16:01:10 J=C3=A9r=C3=A9mie Roquet wrote: > 2017-04-11 15:29 GMT+02:00 J=C3=A9r=C3=A9mie Roquet : > > 2017-04-11 15:00 GMT+02:00 Kamil Dudka : > >> The following shell script crashes zsh (tested with zsh-5.3.1-90- g63f086d): > >> function foo() { > >> =20 > >> if true; then > >> =20 > >> foo > >> =20 > >> fi > >> =20 > >> } > >> =20 > >> foo > >=20 > > That's interesting: > >=20 > > $ zsh -c 'foo() { foo }; foo' > > foo: maximum nested function level reached > >=20 > > $ zsh -c 'foo() { if true; then foo; fi }; foo' > > Segmentation fault >=20 > That looks like a stack overflow=E2=80=A6 >=20 > Doing either of the following fixed the issue for me: > - recompile after =E2=80=9C./configure --enable-max-function-depth=3D= 500=E2=80=9D > (default is 1000); > - execute after =E2=80=9Culimit -s 16384=E2=80=9D (default for me wa= s 8192). Thanks! I can confirm that the error is handled properly after increas= ing 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=20 shell call recursion limit is reached. Kamil > Best regards,