develooper Front page | perl.perl5.porters | Postings from March 2003

Re: Parse::RecDescent triggers infinete loop in perl5.9.0 and 5.8.1 [perl #17757]

From:
Enache Adrian
Date:
March 20, 2003 17:45
Subject:
Re: Parse::RecDescent triggers infinete loop in perl5.9.0 and 5.8.1 [perl #17757]
Message ID:
20030321014410.GA909@ratsnest.hole
On Fri, Mar 21, 2003 at 12:29:18AM +0000, hv@crypt.org wrote:
> It hasn't been established yet precisely what is going wrong, but it
> seems likely based on available evidence that #18533 was either wrong
> or insufficient. In particular, given that the symptom is a hard loop
> in intuit_start, it seems unlikely that P::RD is to blame. I'll be
> looking to discover more detail as soon as a tuit presents itself.
> 
> Hugo

The faulty regexp in RecDescent.pm is this, at line 1856
                elsif ($grammar =~ m/(?=$ACTION)/gco

The second time the _generate method runs, fbm_instr() will be called
at regexec.c:622 with a random pointer as it second argument, pointer
generated with some small adjustments from that prog->subbeg -
        if (s && RX_MATCH_COPIED(prog))
		    s = prog->subbeg + (s - SvPVX(sv));
(the stale pointer from the first run, I guess (?) - notice
 that the grammar string in the example is a mortal, returned
 by a sub, i.e. it is each time a different pointer )

If that pointer happens to be behind 't', an infinite loop happens.

P::RD could be easily 'fixed' <:( by removing the 'study $grammar'
at line 1829.

Regards
Adi



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About