Skip Menu |
Report information
Id: 125825
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: rolf.langsdorf [at] googlemail.com
Cc:
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: (no value)
Type: core
Perl Version: 5.20.2
Fixed In: 5.22.1



To: perlbug [...] perl.org
Subject: {n}+ possessive quantifier broken in 5.20
From: rolf langsdorf <rolf.langsdorf [...] googlemail.com>
Date: Mon, 17 Aug 2015 02:15:01 +0200
Download (untitled) / with headers
text/plain 4.3k
This is a bug report for perl from perl.lanx@gmail.com, generated with the help of perlbug 1.40 running under perl 5.20.2. ----------------------------------------------------------------- [Please describe your issue here] Within regexes "{n}+" is like in "(sub-expression){n}+" a so called "possessive quantifier" to mark sub-expressions atomic and thus avoid back-tracking. And according to perlre the following equivalence applies: PAT{min,max}+ (?>PAT{min,max}) this is true for 5.14 but not anymore for 5.20 ------ Test in 5.20 DB<2> print "aaa" =~ /(?>(a+))a/ DB<3> print "aaa" =~ /(a+){1}+a/ aa DB<4> print "aaa" =~ /(a+){1}a/ aa DB<5> print $] 5.020002 ------- Test in 5.14 DB<1> print "aaa" =~ /(?>(a+))a/ DB<2> print "aaa" =~ /(a+){1}+a/ DB<3> print "aaa" =~ /(a+){1}a/ aa DB<4> print $] 5.014002 ------- Furthermore from 5.20 on a non-sensical warning is emitted, telling that the "possessive" quantifier {n}+ may be a redundant use of "greedy" quantifier. example: Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/\A ((a| +b){2}){1}+ <-- HERE \z/ at 1345_SoPW.pl line 27, <DATA> line 2. see http://www.perlmonks.org/?node_id=1138774 and surrounding thread for more details and tests, including a "use re 'debug'" output. cheers Rolf [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=critical --- Site configuration information for perl 5.20.2: Configured by lanx at Sun Aug 16 23:36:56 CEST 2015. Summary of my perl5 (revision 5 version 20 subversion 2) configuration: Platform: osname=linux, osvers=3.13.0-61-generic, archname=i686-linux uname='linux lanx-1005ha 3.13.0-61-generic #100~precise1-ubuntu smp wed jul 29 12:07:07 utc 2015 i686 i686 i386 gnulinux ' config_args='-de -Dprefix=/home/lanx/perl5/perlbrew/perls/perl-5.20.2 -Aeval:scriptdir=/home/lanx/perl5/perlbrew/perls/perl-5.20.2/bin' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.6.3', 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='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /usr/lib/gcc/i686-linux-gnu/4.6/include-fixed /usr/include/i386-linux-gnu /usr/lib /lib/i386-linux-gnu /lib/../lib /usr/lib/i386-linux-gnu /usr/lib/../lib /lib libs=-lnsl -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=libc-2.15.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.15' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector' --- @INC for perl 5.20.2: /home/lanx/perl5/perlbrew/perls/perl-5.20.2/lib/site_perl/5.20.2/i686-linux /home/lanx/perl5/perlbrew/perls/perl-5.20.2/lib/site_perl/5.20.2 /home/lanx/perl5/perlbrew/perls/perl-5.20.2/lib/5.20.2/i686-linux /home/lanx/perl5/perlbrew/perls/perl-5.20.2/lib/5.20.2 . --- Environment for perl 5.20.2: HOME=/home/lanx LANG=de_DE.UTF-8 LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/lanx/perl5/perlbrew/bin:/home/lanx/perl5/perlbrew/perls/perl-5.20.2/bin:/home/lanx/perl/bin:/home/lanx/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games PERLBREW_BASHRC_VERSION=0.71 PERLBREW_HOME=/home/lanx/.perlbrew PERLBREW_MANPATH=/home/lanx/perl5/perlbrew/perls/perl-5.20.2/man PERLBREW_PATH=/home/lanx/perl5/perlbrew/bin:/home/lanx/perl5/perlbrew/perls/perl-5.20.2/bin PERLBREW_PERL=perl-5.20.2 PERLBREW_ROOT=/home/lanx/perl5/perlbrew PERLBREW_VERSION=0.71 PERL_BADLANG (unset) SHELL=/bin/bash
Subject: Re: [perl #125825] {n}+ possessive quantifier broken in 5.20
From: Dave Mitchell <davem [...] iabyn.com>
To: perl5-porters [...] perl.org
Date: Mon, 17 Aug 2015 14:56:59 +0100
Download (untitled) / with headers
text/plain 1.5k
On Sun, Aug 16, 2015 at 05:15:46PM -0700, rolf langsdorf wrote: Show quoted text
> Within regexes "{n}+" is like in "(sub-expression){n}+" a so called > "possessive quantifier" to mark sub-expressions atomic and thus > avoid back-tracking. > > And according to perlre the following equivalence applies: > > PAT{min,max}+ (?>PAT{min,max}) > > this is true for 5.14 but not anymore for 5.20 > > > ------ Test in 5.20 > > DB<2> print "aaa" =~ /(?>(a+))a/ > > DB<3> print "aaa" =~ /(a+){1}+a/ > aa > DB<4> print "aaa" =~ /(a+){1}a/ > aa > DB<5> print $] > 5.020002 > > > ------- Test in 5.14 > > DB<1> print "aaa" =~ /(?>(a+))a/ > > DB<2> print "aaa" =~ /(a+){1}+a/ > > DB<3> print "aaa" =~ /(a+){1}a/ > aa > DB<4> print $] > 5.014002 > > ------- > > Furthermore from 5.20 on a non-sensical warning is emitted, > telling that the "possessive" quantifier {n}+ may be a redundant use > of "greedy" quantifier. > > example: > > Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/\A ((a| > +b){2}){1}+ <-- HERE \z/ at 1345_SoPW.pl line 27, <DATA> line 2. > > > see http://www.perlmonks.org/?node_id=1138774 and surrounding thread > for more details and tests, including a "use re 'debug'" output.
It bisects to this: commit 4fa6dd16d2149c2aeeb32633e3a796d5ebc5b657 Author: Karl Williamson <public@khwilliamson.com> Date: Fri Dec 6 15:50:52 2013 -0700 PATCH: [Perl #42957] Suggesting warning for useless greediness operator This adds the requested warning. Now we'll see if anything breaks as a result. -- My get-up-and-go just got up and went.
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 117b
Thanks for reporting this. Now fixed in blead by commit 9a7bb2f73a8a1b561890191974201d576371e7f9 -- Karl Williamson


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org