develooper Front page | perl.perl5.porters | Postings from April 2007

[perl #42422] regexp matches erroneusly when backtracking is disabled

Thread Next
From:
Jan Chorowski
Date:
April 10, 2007 14:26
Subject:
[perl #42422] regexp matches erroneusly when backtracking is disabled
Message ID:
rt-3.6.HEAD-8429-1176219951-1358.42422-75-0@perl.org
# New Ticket Created by  Jan Chorowski 
# Please include the string:  [perl #42422]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42422 >


Hi,

on my configuration (Gentoo linux, perl 5.8.8), when running the
following file:

#!/usr/bin/perl
"dummy dummy { ;" =~
m{(
^(
  [^;{}]
  (?>  #<--- disabled backtracking
      (\s|\\\n)*                      # treat escaped \n as space
      (// ([^\n]|\\\n)* (?<!\\)\n)?   # skip // comments
  )*
 )+?
;        
)}xs && print '$&: |',$&,"|\n",'$1: |',$1,"|\n";

I get:

$&: |dummy dummy |
$1: ||

which means that the match succeeded (though it should fail- there is
no semicolon) and the $1 variable is unset.

The regexp fails, as expected, when I enable backtracking in the marked
place.

I was able to reproduce this on Debian, perl v5.8.8.
After a post to the beginners mailing list Tom Phoenix has reported
this to work correctly ob perl 5.8.6.

Thanks,
Jan Chorowski

---
Flags:
    category=core
    severity=medium/low
---
Site configuration information for perl v5.8.8:

Configured by Gentoo at Wed Sep 13 13:01:49 CEST 2006.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.6.17-gentoo-r7, archname=i686-linux
    uname='linux linux 2.6.17-gentoo-r7 #3 smp fri sep 8 10:47:33 cest
2006 i686 intel(r) pentium(r) 4 cpu 3.00ghz genuineintel gnulinux '
config_args='-des -Darchname=i686-linux -Dcccdlflags=-fPIC
-Dccdlflags=-rdynamic -Dcc=i686-pc-linux-gnu-gcc -Dprefix=/usr
-Dvendorprefix=/usr -Dsiteprefix=/usr -Dlocincpth=
-Doptimize=-march=pentium4 -O2 -pipe -Duselargefiles -Dd_semctl_semun
-Dscriptdir=/usr/bin -Dman1dir=/usr/share/man/man1
-Dman3dir=/usr/share/man/man3 -Dinstallman1dir=/usr/share/man/man1
-Dinstallman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm
-Dinc_version_list=5.8.0 5.8.0/i686-linux 5.8.2 5.8.2/i686-linux 5.8.4
5.8.4/i686-linux 5.8.5 5.8.5/i686-linux 5.8.6 5.8.6/i686-linux 5.8.7
5.8.7/i686-linux  -Dcf_by=Gentoo -Ud_csh -Dusenm -Di_ndbm -Di_gdbm
-Di_db -Dd_dosuid' hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef useperlio=define d_sfio=undef
uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef
uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler:
cc='i686-pc-linux-gnu-gcc', ccflags ='-fno-strict-aliasing -pipe
-Wdeclaration-after-statement -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64', optimize='-march=pentium4 -O2 -pipe',
cppflags='-fno-strict-aliasing -pipe -Wdeclaration-after-statement'
ccversion='', gccversion='4.1.1 (Gentoo 4.1.1)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8 alignbytes=4, prototype=define Linker and Libraries:
ld='i686-pc-linux-gnu-gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib libs=-lpthread -lnsl -lndbm -lgdbm
-ldb -ldl -lm -lcrypt -lutil -lc perllibs=-lpthread -lnsl -ldl -lm
-lcrypt -lutil -lc libc=/lib/libc-2.4.so, so=so, useshrplib=false,
libperl=libperl.a gnulibc_version='2.4' Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.8.8:
    /etc/perl
    /usr/lib/perl5/vendor_perl/5.8.8/i686-linux
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/site_perl/5.8.8/i686-linux
    /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/5.8.8/i686-linux
    /usr/lib/perl5/5.8.8
    /usr/local/lib/site_perl
    .

---
Environment for perl v5.8.8:
    HOME=/root
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE=pl_PL
    LD_LIBRARY_PATH=/root/GNUstep/Library/Libraries:/usr/GNUstep/Local/Library/Libraries:/usr/GNUstep/Network/Library/Libraries:/usr/GNUstep/System/Library/Libraries:/opt/intel/mkl/8.1/lib/32
    LOGDIR (unset)
    PATH=/root/GNUstep/Tools:/usr/GNUstep/Local/Tools:/usr/GNUstep/Network/Tools:/usr/GNUstep/System/Tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.1.1:/opt/intel/compiler91/bin:/opt/intel/fortran91/bin:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin:/usr/kde/3.5/sbin:/usr/kde/3.5/bin:/usr/qt/3/bin:/opt/smlnj/bin/
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


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