[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Segfault after many stackframes

From: Andrew Church
Subject: Re: Segfault after many stackframes
Date: Sat, 13 Apr 2019 02:12:59 +0900

>This recursive function causes bash to segfault:
>$ re() { t=$((t+1)); if [[ $t -gt 8000000 ]]; then echo foo; return;
>fi; re; }; re
>Segmentation fault (core dumped)
>Ideally Bash ought to run out of memory before this fails. But an
>acceptable solution could also be to say 'stack overflow'.

That's exactly what bash is saying there.  I'm not sure what (if
anything) POSIX specifies for stack overflow behavior, but at least on
Linux, stack overflow raises SIGSEGV:

$ echo 'int main(void) {return main();}' | cc -o foo -x c -
$ ./foo
Segmentation fault

  --Andrew Church

reply via email to

[Prev in Thread] Current Thread [Next in Thread]