>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
    http://achurch.org/

Reply via email to