bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] gawk 4.2.1 critical issue


From: arnold
Subject: Re: [bug-gawk] gawk 4.2.1 critical issue
Date: Sun, 25 Mar 2018 09:12:57 -0600
User-agent: Heirloom mailx 12.4 7/29/08

I looked at it also. It's the tail recursion optimization, which has
a day 1 bug; it frees the local variables but doesn't take into account
that one of the locals might be a parameter, which is what Denis's code
does. (See setup_frame in eval.c.)

Indeed, if gawk 4.1.4 is run on this program with the -O option, which
enables optimizations, it will fail in the same way.

I will see if I can fix the code; if not then I will probably just remove
the tail recursion optimization.

Thanks Denis for the report.

Arnold

"Andrew J. Schorr" <address@hidden> wrote:

> Hi,
>
> Thanks for the bug report. I ran git bisect on this, and here is where
> the trouble started:
>
> d18edce5957afdc3a286cf4ce1ca141a3cdc7be5 is the first bad commit
> commit d18edce5957afdc3a286cf4ce1ca141a3cdc7be5
> Author: Arnold D. Robbins <address@hidden>
> Date:   Fri Feb 5 10:02:09 2016 +0200
>
>     Turn optimization on by default. New -s option to disable it.
>
> :100644 100644 9c0dedd415abce5d8a247fd029cb510b8e5fd7ec 
> b67eabb8975fd658a06e2c598da466681b11dc37 M      ChangeLog
> :100644 100644 8383b805e49ba28406728f0bbebfb347873da347 
> 353cf6859509339e471b8f3d3023a09ffba15b23 M      NEWS
> :100644 100644 61a6de9dde878ea740236dcaacf62af97c3aefb2 
> d50040b3a890b2791b435488a6e45da02eec85ee M      awkgram.c
> :100644 100644 11702186f31bf04386cbb7a67c01fcdbc49925da 
> 593eddd8ed6da3ef57ec057627307322e971f1dd M      awkgram.y
> :040000 040000 e76d55269ffe95739f822291b8455a69702fc960 
> fb7e870ab6f9c23a9789dd992a3db01c70d88d82 M      doc
> :100644 100644 b17ab309cada94567b92c5a0a1119f6c07bfb01b 
> 8537aa78e1f8f8359dfb549b4f7db0dad6d2ccde M      main.c
> :040000 040000 a9f5347bc38c0269b66c1cac462a5385c4bacffa 
> 1416e0866440eb2522db2eb9628725669c717227 M      test
>
> And I confirmed that running with the -s option gives the correct result
> matching 4.1.4. I haven't had time to debug further...
>
> Regards,
> Andy
>
> On Sun, Mar 25, 2018 at 02:34:40PM +0300, Denis Shirokov wrote:
> > note: if we are runing same script by gawk 4.1.4 then we will have the
> > following output
> > 
> > abc(2, 0)
> > 1
> > abc(1, 1)
> > 1
> > abc(0, 1)
> > 
> > 
> > thnx
> > 
> > 2018-03-25 14:30 GMT+03:00, Denis Shirokov <address@hidden>:
> > > # hello
> > > #
> > > # found another critical issue for gawk 4.2.1
> > > #
> > > # the following is the gawk 4.2.1 code for reproducing the issue
> > > #
> > >
> > > func      abc(c, A, B) {
> > >
> > >    print "abc(" c ", " length(A) ")"
> > >
> > >    if ( !c-- )
> > >
> > >       return
> > >   
> > >    B[""]; print length(B)
> > >   
> > >    return abc(c, B) }
> > >
> > > BEGIN {
> > >
> > >    abc(2)
> > >
> > >    }
> > >
> > > output:
> > >
> > >>gawk -f r.gwk
> > >  abc(2, 0)
> > >  1
> > >  abc(1, 0)
> > >  gawk: r.gwk:9: fatal: attempt to use scalar parameter `B' as an array
> > >
> > > # we have user defined function abc() that is calling itself recursively
> > > # function have two parameters and one local array that is passing
> > > # as the second parameter while recursive function call.
> > >
> > > # please pay attention that local array B isn't present as the
> > > parameter after function
> > > # recursive call
> > >
> > > # GNU Awk 4.2.1, API: 2.0 (GNU MPFR 3.1.0-p8, GNU MP 5.0.2)
> > > # Copyright (C) 1989, 1991-2018 Free Software Foundation.
> > >
> > > # Win7x64SP1
> > >
> > > # with respect
> > > # Denis Shirokov
> > >
>
> -- 
> Andrew Schorr                      e-mail: address@hidden
> Telemetry Investments, L.L.C.      phone:  917-305-1748
> 545 Fifth Ave, Suite 1108          fax:    212-425-5550
> New York, NY 10017-3630



reply via email to

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