develooper Front page | perl.perl5.porters | Postings from November 2006

[perl #6893] \G with /h results in infinite loop in 5.6 and later

Thread Previous
yves orton via RT
November 18, 2006 08:22
[perl #6893] \G with /h results in infinite loop in 5.6 and later
Message ID:
On Wed Apr 25 06:17:47 2001, wrote:
> Hi.  The attached program behaves differently on 5.005 and
> 5.6.  The relevant part is the regular expression
> m#(\G|\n)([^\n]*)\n#gsx, which under 5.005 iterates through
> every line in the string, but under 5.6 gets stuck on the second
> line and loops forever.
> I don't know if this was a bug in 5.005 that is now fixed, but
> I can't figure out why it doesn't work.

This bug persists in blead perl (v5.9.5).

The attached patch fixes the immediate issue, but results in 


failing some tests so it cant be applied. The test part could be
converted to a TODO however and applied regardless.

I have to say that the way /g code is handled in pp_match doesnt make a
lot of sense to me, and some parts of it are IMO highly suspect. I dont
think anything outside of the regexe engine should be assigning to the
paren buffers, especially not without taking measures to undo the change
in the case of a failed match.

Anyway, im investigating further but assistance or advice would be welcome.

Also I am renaming the bug to more accurately describe the underlying issue.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About