Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.94k stars 554 forks source link

regexp matching against studied var fails inside sort #4545

Closed p5pRT closed 20 years ago

p5pRT commented 22 years ago

Migrated from rt.perl.org#7866 (status was 'resolved')

Searchable as RT7866$

p5pRT commented 22 years ago

From x.perlbug@chatterjee.net

The following code hangs when run under perl 5.6.1. It runs just fine under 5.005_03\, and possibly other versions.

  my @​strings = (''\, '..');   my @​sorted = sort {   study $a;   return 1 if (($a =~ m/\w\.$/) && ($b !~ m/\.$/));   return 0;   } @​strings;

This works fine if the study is removed. It also works fine outside the context of a sort.

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl v5.6.1: Configured by anirvan at Mon May 14 18:09:59 PDT 2001. Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=linux, osvers=2.2.16-22, archname=i686-linux uname='linux anonymous.host 2.2.16-22 #1 tue aug 22 16:49:06 edt 2000 i686 unknown ' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -I/product/share/app/include -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fno-strict-aliasing -I/product/share/app/include -I/usr/local/include' ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.0)', 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, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags ='-L/product/share/app/lib -L/usr/local/lib' libpth=/product/share/app/lib /usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldl -lm -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil libc=/lib/libc-2.2.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/product/share/app/lib -L/usr/local/lib' Locally applied patches: @INC for perl v5.6.1: /dist/share/system/src /dist/share/app/lib/perl5/5.6.1/i686-linux /dist/share/app/lib/perl5/5.6.1 /dist/share/app/lib/perl5/site_perl/5.6.1/i686-linux /dist/share/app/lib/perl5/site_perl/5.6.1 /dist/share/app/lib/perl5/site_perl . Environment for perl v5.6.1: HOME=/home/anirvan LANG=en_US LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/product/share/app/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin PERL5LIB=/dist/share/system/src PERL_BADLANG (unset) SHELL=/bin/tcsh ```
p5pRT commented 22 years ago

From [Unknown Contact. See original ticket]

The following code hangs when run under perl 5.6.1. It runs just fine under 5.005_03\, and possibly other versions.

  my @​strings = (''\, '..');   my @​sorted = sort {   study $a;   return 1 if (($a =~ m/\w\.$/) && ($b !~ m/\.$/));   return 0;   } @​strings;

This works fine if the study is removed. It also works fine outside the context of a sort.

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl v5.6.1: Configured by anirvan at Mon May 14 18:09:59 PDT 2001. Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=linux, osvers=2.2.16-22, archname=i686-linux uname='linux anonymous.host 2.2.16-22 #1 tue aug 22 16:49:06 edt 2000 i686 unknown ' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -I/product/share/app/include -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fno-strict-aliasing -I/product/share/app/include -I/usr/local/include' ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.0)', 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, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags ='-L/product/share/app/lib -L/usr/local/lib' libpth=/product/share/app/lib /usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldl -lm -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil libc=/lib/libc-2.2.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/product/share/app/lib -L/usr/local/lib' Locally applied patches: @INC for perl v5.6.1: /dist/share/system/src /dist/share/app/lib/perl5/5.6.1/i686-linux /dist/share/app/lib/perl5/5.6.1 /dist/share/app/lib/perl5/site_perl/5.6.1/i686-linux /dist/share/app/lib/perl5/site_perl/5.6.1 /dist/share/app/lib/perl5/site_perl . Environment for perl v5.6.1: HOME=/home/anirvan LANG=en_US LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/product/share/app/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin PERL5LIB=/dist/share/system/src PERL_BADLANG (unset) SHELL=/bin/tcsh ```
p5pRT commented 22 years ago

From @schwern

--- study.t 2001/11/02 04​:16​:23 1.1 +++ study.t 2001/11/02 04​:22​:17 @​@​ -47\,7 +47\,7 @​@​ }

-print "1..26\n"; +print "1..27\n";

$x = "abc\ndef\n"; study($x); @​@​ -117\,5 +117\,9 @​@​   study;   alarm_ok { /G.F$/ };   alarm_ok { /[F]F$/ }; + + $_ = '..'; + study; + alarm_ok { /[a]\.$/ }; # perlbug 20011101.074 }

--

Michael G. Schwern \schwern@​pobox\.com http​://www.pobox.com/~schwern/ Perl6 Quality Assurance \perl\-qa@​perl\.org Kwalitee Is Job One OH GOD!! It's LINUX! All you Linux fanboys go wild! It never crashes! It'll wash your underpants! It'll eat your dog for you\, if you want your dog to be eaten! It'll make you attractive and smell good and... it'll... uh... uh. Man\, I'm so sick of this shit.   http​://www.goats.com/archive/000602.html

p5pRT commented 22 years ago

From [Unknown Contact. See original ticket]

The following code hangs when run under perl 5.6.1. It runs just fine under 5.005_03\, and possibly other versions.

  my @​strings = (''\, '..');   my @​sorted = sort {   study $a;   return 1 if (($a =~ m/\w\.$/) && ($b !~ m/\.$/));   return 0;   } @​strings;

This works fine if the study is removed. It also works fine outside the context of a sort.

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl v5.6.1: Configured by anirvan at Mon May 14 18:09:59 PDT 2001. Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=linux, osvers=2.2.16-22, archname=i686-linux uname='linux anonymous.host 2.2.16-22 #1 tue aug 22 16:49:06 edt 2000 i686 unknown ' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -I/product/share/app/include -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fno-strict-aliasing -I/product/share/app/include -I/usr/local/include' ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.0)', 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, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags ='-L/product/share/app/lib -L/usr/local/lib' libpth=/product/share/app/lib /usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldl -lm -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil libc=/lib/libc-2.2.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/product/share/app/lib -L/usr/local/lib' Locally applied patches: @INC for perl v5.6.1: /dist/share/system/src /dist/share/app/lib/perl5/5.6.1/i686-linux /dist/share/app/lib/perl5/5.6.1 /dist/share/app/lib/perl5/site_perl/5.6.1/i686-linux /dist/share/app/lib/perl5/site_perl/5.6.1 /dist/share/app/lib/perl5/site_perl . Environment for perl v5.6.1: HOME=/home/anirvan LANG=en_US LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/product/share/app/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin PERL5LIB=/dist/share/system/src PERL_BADLANG (unset) SHELL=/bin/tcsh ```
p5pRT commented 22 years ago

From [Unknown Contact. See original ticket]

The following code hangs when run under perl 5.6.1. It runs just fine under 5.005_03\, and possibly other versions.

  my @​strings = (''\, '..');   my @​sorted = sort {   study $a;   return 1 if (($a =~ m/\w\.$/) && ($b !~ m/\.$/));   return 0;   } @​strings;

This works fine if the study is removed. It also works fine outside the context of a sort.

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl v5.6.1: Configured by anirvan at Mon May 14 18:09:59 PDT 2001. Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=linux, osvers=2.2.16-22, archname=i686-linux uname='linux anonymous.host 2.2.16-22 #1 tue aug 22 16:49:06 edt 2000 i686 unknown ' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -I/product/share/app/include -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fno-strict-aliasing -I/product/share/app/include -I/usr/local/include' ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.0)', 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, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags ='-L/product/share/app/lib -L/usr/local/lib' libpth=/product/share/app/lib /usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldl -lm -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil libc=/lib/libc-2.2.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/product/share/app/lib -L/usr/local/lib' Locally applied patches: @INC for perl v5.6.1: /dist/share/system/src /dist/share/app/lib/perl5/5.6.1/i686-linux /dist/share/app/lib/perl5/5.6.1 /dist/share/app/lib/perl5/site_perl/5.6.1/i686-linux /dist/share/app/lib/perl5/site_perl/5.6.1 /dist/share/app/lib/perl5/site_perl . Environment for perl v5.6.1: HOME=/home/anirvan LANG=en_US LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/product/share/app/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin PERL5LIB=/dist/share/system/src PERL_BADLANG (unset) SHELL=/bin/tcsh ```
p5pRT commented 22 years ago

From @vanstyn

Thanks for the report. This bug has already been fixed in the latest development version\, so 5.6.2 and 5.8.0 should both work correctly once they become available.

Unfortunately I do not know of an easy workaround for this bug\, except not to use study when your regexps are end-anchored (ie\, have a '$' anchor). However\, in the example code you show I would be surprised if the study() was gaining you anything - you may want to try doing some benchmarks against perl5.005_03 to verify.

If you desperately need a fix for 5.6.1\, the patch at​:   http​://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-06/msg01000.html should apply at around line 1306 of util.c.

Hope this helps\,

Hugo van der Sanden