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

[perl #118277] Segfault/"Read-only-Variable"-Bug in Regex

Thread Next
Norman Koch
June 4, 2013 04:08
[perl #118277] Segfault/"Read-only-Variable"-Bug in Regex
Message ID:
# New Ticket Created by  Norman Koch 
# Please include the string:  [perl #118277]
# in the subject line of all future correspondence about this issue. 
# <URL: >


I just had some program like this:

use warnings;
use strict;


sub re {
         my $first_param = shift;
         my $second_param = shift;
         my $third_param = shift;

         my $re1 = qr/(?{ die "AAAAAAAAAAA" })/xi;

         if ($first_param =~ /$re1/ix) {
                 return 1;

For some weird reason, this gives me a segmentation fault, that seems to 
be encountering in the eval-regex.

While breaking down this bug into the smallest piece of code that it 
would still occur in, I found another weird thing, that might be 
considered a bug:

If you remove the line "$second_param = shift", so that there are not 3 
Parameters, but only 2 or less, you get this message:

AAAAAAAAAAA at (re_eval 1) line 1.
Modification of a read-only value attempted at (re_eval 1) line 1.
Why exactly is perl doing that? There isn't any variable that's being 
changed as far as I can see (though, this doesn't really crash perl, but 
just show this warning). And why does it need to have 3 shifted 
variables here? I don't get it.

The Perl-version we got here is v5.14.2 and we run debian 7 (Linux 
3.2.0-3-amd64 #1 SMP Mon Jul 23 02:45:17 UTC 2012 x86_64 GNU/Linux)

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