develooper Front page | perl.perl5.porters | Postings from July 2009

[perl #68020] Evil combination of regexes, lexicals, and autovivication

Thread Next
John Peacock
July 30, 2009 03:02
[perl #68020] Evil combination of regexes, lexicals, and autovivication
Message ID:
# New Ticket Created by  John Peacock 
# Please include the string:  [perl #68020]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.36 running under perl 5.10.0.

[Please enter your report here]

Schwern and I simultaneously discovered that some hash tests were 
failing in Damian's Regex::Grammars.  But it turns out to be some 
insideous combination of regexes, lexicals, and autovivication and not 
depend on R::G at all.  Damian came up with the following script:

   use 5.010;

   my $rx = qr{ (?{ @arr = [1]; $arr[-1][0] = 0; my $var; }) }x;

   #my $dummy1 = '';
   #my $dummy2 = '';

   my $line = "";
   $line =~ $rx;

   say 'fail' if !defined $line;

If I run it as is, I get a segfault.  If I uncomment one of the
$dummy assignments, it passes.  If I uncomment both $dummy assignments,
I get:

   Modification of a read-only value attempted at line 9.

On the other hand, Damian got a completely different sort of behavior:

> Interestingly, injecting one *extra* lexical declaration anywhere in the
> code (outside the (?{...}) that is) has no effect. But injecting *two*
> lexicals anywhere in the code also stops the match from undefinng $line.
> Whereas injecting a second lexical inside the (?{...}) is giving me a
> bus error.

I told Damian I would file this bug and try and answer any questions
(he's in full conference travel mode).

[Please do not change anything below this line]
Site configuration information for perl 5.10.0:

Configured by Message Systems, Inc. at Mon Jan 12 16:03:50 EST 2009.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
     osname=linux, osvers=2.6.18-92.1.22.el5, 
     uname='linux jpeacock 2.6.18-92.1.22.el5 #1 smp tue dec 16 11:57:43 
est 2008 x86_64 x86_64 x86_64 gnulinux '
     config_args='-des -Uusedtrace -Dmyhostname=localhost 
-Dperladmin=root@localhost -Dcc=/opt/msys/3rdParty/bin/ccache gcc 
-Accflags=-O2 -g -Aldflags= -Alddlflags= -shared -Dcf_by=Message 
Systems, Inc. -Dlibpth=/lib64 /usr/lib64 -Darchname=x86_64-linux 
-Duseshrplib -Di_shadow -Ulocincpth 
-Dlocincpth=/opt/msys/3rdParty/include -Uloclibpth 
-Dloclibpth=/opt/msys/3rdParty/lib -Ui_gdbm -Dusethreads -Duselargefiles 
-Dd_semctl_semun -Di_db -Ui_ndbm -Di_syslog -Dman3ext=3pm 
-Dman3dir=/opt/msys/3rdParty/man/man3 -Duseperlio -Uinstallusrbinperl 
-Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr 
-Dusemultiplicity -Dvendorprefix=/opt/msys -Dprefix=/opt/msys/3rdParty'
     hint=recommended, useposix=true, d_sigaction=define
     useithreads=define, usemultiplicity=define
     useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
     use64bitint=define, use64bitall=define, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
     cc='/opt/msys/3rdParty/bin/ccache gcc', ccflags ='-D_REENTRANT 
-D_GNU_SOURCE -O2 -g -fno-strict-aliasing -pipe 
-I/opt/msys/3rdParty/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 
     cppflags='-D_REENTRANT -D_GNU_SOURCE -O2 -g -fno-strict-aliasing 
-pipe -I/opt/msys/3rdParty/include -I/usr/include/gdbm'
     ccversion='', gccversion='4.1.2 20071124 (Red Hat 4.1.2-42)', 
     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
     ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', 
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='/opt/msys/3rdParty/bin/ccache gcc', ldflags =' '
     libpth=/lib64 /usr/lib64
     libs=-lnsl -lgdbm -ldl -lm -lcrypt -lutil -lpthread -lc
     perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
     libc=/lib/, so=so, useshrplib=true,
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E 
     cccdlflags='-fPIC', lddlflags='  -shared'

Locally applied patches:

@INC for perl 5.10.0:

Environment for perl 5.10.0:
     LANGUAGE (unset)
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PERL_BADLANG (unset)

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