develooper Front page | perl.perl5.porters | Postings from June 2019

[perl #134209] Regex stores wrong value in $1, $^N etc, thoroughlycorrupting parsers

Thread Previous
From:
Tony Cook via RT
Date:
June 19, 2019 00:56
Subject:
[perl #134209] Regex stores wrong value in $1, $^N etc, thoroughlycorrupting parsers
Message ID:
rt-4.0.24-28129-1560905778-208.134209-15-0@perl.org
On Tue, 18 Jun 2019 13:37:38 -0700, jamie wrote:
> [Please describe your issue here]
> 
> Hi,
> 
> The following short Perl program shows the error:
> 
> sub S { "A" =~ /(.)(?{})/; }
> "xyz" =~ /(?:(.)(?{say $1;S()}))*/;
> 
> Output should be:
> 
> x
> y
> z
> 
> Actual output is:
> 
> x
> A
> A
> 
> This is because the value stored in $1 is incorrect.

I'm not suggesting this isn't a bug, but has it ever worked the way you expect?

I tried perls back to 5.10:

$ ~/perl/5.10.0-debug/bin/perl ../134209.pl 
x
Assertion rx->sublen >= (s - rx->subbeg) + i failed: file "regcomp.c", line 5098 at (re_eval 2) line 1.

A non-debug perl 5.10 produced corrupted output and an out of memory error.

$ ~/perl/5.12.0/bin/perl ../134209.pl 
x
/
x

$ ~/perl/5.14.2-debug/bin/perl ../134209.pl 
x
A
A

$ ~/perl/5.16.3/bin/perl ../134209.pl 
x
A
A

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=134209

Thread Previous


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