Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: unbounded recursive call in a shell script crashes zsh



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).

Best regards,

-- 
Jérémie



Messages sorted by: Reverse Date, Date, Thread, Author