bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: unfinite recursion causes segfault


From: Aharon Robbins
Subject: Re: unfinite recursion causes segfault
Date: Tue, 29 Jan 2008 08:13:48 +0200

Greetings: Re this:

> To: address@hidden
> Subject: unfinite recursion causes segfault
> From: Aleksey Cheusov <address@hidden>
> Date: Mon, 28 Jan 2008 15:06:22 +0200
>
> By mistake I created a script that runs an unfinite recursion.
> Gawk, instead of handling this situation correctly, just segfaults.
>
> Both gawk 3.1.5 and 3.1.6 segfault.
>
> ========================== script =====================
> #!/usr/bin/gawk -f
>
> function rec2 (num){
>       rec2(num+1)
> }
>
> BEGIN {
>       rec2(0)
>       exit 77
> }
>
> ====================== backtrace ======================
> (gdb) bt
> #0  0xb7e03a0f in free () from /lib/tls/i686/cmov/libc.so.6
> #1  0xb7e059ef in malloc () from /lib/tls/i686/cmov/libc.so.6
> #2  0x0808475f in interpret ()
> #3  0x08081a79 in r_tree_eval ()
> #4  0x08083456 in interpret ()
> #5  0x08084c81 in interpret ()
> #6  0x08081a79 in r_tree_eval ()
> ...
>
> -- 
> Best regards, Aleksey Cheusov.

Thank you for the report.  The Bell Labs awk and mawk also core dump
on this program, which is not surprising.

In general, it is difficult, if not impossible, to distinguish infinite
recursion from merely "very deep" recursion, without imposing an arbitrary
limit on function call nesting level.  Doing this goes against the
GNU design principle of "no arbitrary limits".

Also, how would gawk choose a limit? On systems with 128M of memory the
limit should be smaller than on a system with 2G of memory.

In this case, causing gawk to core dump is just as effective a way to
discover a mistaken infinite recursion as is an error message. :-)

If you have other suggestions, I'll be happy to hear them.

Thanks,

Arnold




reply via email to

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