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 18, 2003 16:14
Subject:
Re: Parse::RecDescent triggers infinete loop in perl5.9.0 and 5.8.1 [perl #17757]
Message ID:
20030319001144.GA30464@ratsnest.hole
On Mon, Mar 10, 2003 at 05:56:17AM +0000, hv@crypt.org wrote:
> David Dyck <david.dyck@fluke.com> wrote:
> :The following code using Parse::RecDescent does
> :an infinite loop with perl5.9.0  (presuming with 5.8.1)
> :but finishes fine with perl5.8.0.  I haven't simplified
> :this as much as I could yet, the grammar comes
> :from derived from Inline::C::ParseRecDescent, where
> :I first saw the problem in its make test.
> 
> Here's another step of simplification:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> sub get_parser {
>     require Parse::RecDescent;
>     $main::RD_HINT++;
>     Parse::RecDescent->new(grammar())
> }
> 
> 
> sub grammar {
>     <<'END';
> code:   'x' { '...' }
> END
> }
> 
> BEGIN { $::RD_TRACE = 1; }
> 
> get_parser()->code('x');
> get_parser()->code('x');
> __END__

The infinite loop happens in re_intuit_start. It always 'goto restart'
at line 648 in regexec.c.

	s = fbm_instr( ...
at line 622 return NULL; which itself isn't that amazing since its
'bigend' argument happens to lag behind 'big' ( see util.c:426 )

It's caused by this:
        /* we may be pointing at the wrong string */
	if (s && RX_MATCH_COPIED(prog))
	    s = prog->subbeg + (s - SvPVX(sv))
(regexec.c:546)

Removing those lines stops cures that infinite loop;
They're there since
Change 18533 by hv@hv-crypt.org on 2003/01/21 02:15:29

        Subject: Re: [perl #17757] s///g fails when using English & study in 5.8.0

Hoping this helps,

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