develooper Front page | perl.perl5.porters | Postings from August 2008

Wrong RE match in 5.10.0

Thread Next
Gisle Aas
August 23, 2008 00:56
Wrong RE match in 5.10.0
Message ID:
In the Data::Dump module I had the following (stupid) regular  
expression that ends up dumping core in 5.8 when the RE engine blows  
the stack.  I'm fine with that, but what caught my eye was that  
5.10.0 which avoids the segfault simply return the wrong match.  I  
think it would have been better for it to raise an exception if it  
refuse to loop longer than to return the wrong result.



for (1, 10, 100) {
     $str = "x" x ($_ * 1024);
     if ($str =~ /^(.{1,5}?)(\1*)\z/s) {
         print "$1 ", length($2), "\n";
     else {
         print "no match\n";


With 5.8 this prints:

x 1023
x 10239
Segmentation fault

With 5.10 this prints:

x 1023
x 10239
xxxx 102396

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