Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qr/\88/ hangs (Bleadperl breaks JE again) #10665

Closed
p5pRT opened this issue Sep 26, 2010 · 7 comments
Closed

qr/\88/ hangs (Bleadperl breaks JE again) #10665

p5pRT opened this issue Sep 26, 2010 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 26, 2010

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

Searchable as RT78058$

@p5pRT
Copy link
Author

p5pRT commented Sep 26, 2010

From @cpansprout

This one-liner hangs during regexp compilation​:
perl5.13.5 -e 'qr/\88/'

In perl5.13.4 it compiles successfully, but qr/\9/ dies, because it is an invalid backreference.

I think the correct behaviour is for qr/\88/ to die the same way.

Note also that it does not hang if the second digit is a valid octal digit​:
$ perl5.13.5 -le 'print qr/\87/'
(?-xism​:\87)

This was caused by​:

From c99e91e Mon Sep 17 00​:00​:00 2001
From​: Karl Williamson <khw@​khw-desktop.(none)>
Date​: Sun, 18 Jul 2010 12​:28​:14 -0600
Subject​: [PATCH] Fix /[\8]/ to not match NULL; give correct warning

8 and 9 are not treated as alphas in parsing as opposed to illegal
octals.

This also adds tests to verify that 1-3 digits work in char classes.

I created an isOCTAL macro in case that lookup gets moved to a bit
field, as I plan to do later, for speed.


Flags​:
  category=core
  severity=high
  category=parsing
  category=regex


Site configuration information for perl 5.13.5​:

Configured by sprout at Sun Sep 19 17​:34​:01 PDT 2010.

Summary of my perl5 (revision 5 version 13 subversion 5 patch v5.13.5-8-g8e58c70) configuration​:
  Snapshot of​: 8e58c70
  Platform​:
  osname=darwin, osvers=10.4.0, archname=darwin-thread-multi-2level
  uname='darwin pint.local 10.4.0 darwin kernel version 10.4.0​: fri apr 23 18​:28​:53 pdt 2010; root​:xnu-1504.7.4~1release_i386 i386 '
  config_args='-de -Dusedevel -DDEBUGGING -Duseithreads'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=define, usemultiplicity=define
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
  optimize='-O3 -g',
  cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.2.1 (Apple Inc. build 5664)', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lutil -lc
  perllibs=-ldl -lm -lutil -lc
  libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'

Locally applied patches​:
 


@​INC for perl 5.13.5​:
  /usr/local/lib/perl5/site_perl/5.13.5/darwin-thread-multi-2level
  /usr/local/lib/perl5/site_perl/5.13.5
  /usr/local/lib/perl5/5.13.5/darwin-thread-multi-2level
  /usr/local/lib/perl5/5.13.5
  /usr/local/lib/perl5/site_perl
  .


Environment for perl 5.13.5​:
  DYLD_LIBRARY_PATH (unset)
  HOME=/Users/sprout
  LANG=en_US.UTF-8
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/bin​:/bin​:/usr/sbin​:/sbin​:/usr/local/bin​:/usr/X11/bin​:/usr/local/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2010

From @khwilliamson

The attached patch fixes this. Note that the circumstances when this
bug happened are if the first digit is any of [1-9], and the second
digit is [89]. I think it doesn't happen if the number of capture
groups is at least this two digit number.

Note that qr/\88/ means qr/\00088/. I consider this a bug, but others
says it has to be this way for backward compatiblity.

@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2010

From @khwilliamson

0001-regcomp.c-perl-78058-qr-18-loops.patch
From 039c541858ae9a7b3fb2962ade008b1b2a704b57 Mon Sep 17 00:00:00 2001
From: Karl Williamson <public@khwilliamson.com>
Date: Tue, 28 Sep 2010 14:44:08 -0600
Subject: [PATCH] regcomp.c [perl #78058] qr/\18/ loops

This patch restores the behavior of /\18/ to mean /\0018/, which was
inadvertently changed by c99e91e919b4bb89bab7829a9026ee01b1fff2a1.

This bug happens when t the first digit is [1-9], and the
second [89].
---
 regcomp.c |    2 +-
 t/re/re.t |    9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/regcomp.c b/regcomp.c
index ff9f87b..bcdc65f 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -7601,7 +7601,7 @@ tryagain:
 		    case '0': case '1': case '2': case '3':case '4':
 		    case '5': case '6': case '7': case '8':case '9':
 			if (*p == '0' ||
-			    (isOCTAL(p[1]) && atoi(p) >= RExC_npar))
+			    (isDIGIT(p[1]) && atoi(p) >= RExC_npar))
 			{
 			    I32 flags = PERL_SCAN_SILENT_ILLDIGIT;
 			    STRLEN numlen = 3;
diff --git a/t/re/re.t b/t/re/re.t
index 76835f0..ecbcb29 100644
--- a/t/re/re.t
+++ b/t/re/re.t
@@ -53,13 +53,18 @@ if ('1234'=~/(?:(?<A>\d)|(?<C>!))(?<B>\d)(?<A>\d)(?<B>\d)/){
     is(regnames_count(),3);
 }
 
-    { # Keep this test last, as whole script will be interrupted if times out
+    { # Keep these tests last, as whole script will be interrupted if times out
         # Bug #72998; this can loop 
         watchdog(2);
         eval '"\x{100}\x{FB00}" =~ /\x{100}\N{U+66}+/i';
         pass("Didn't loop");
+
+        # Bug #78058; this can loop
+        watchdog(2);
+        eval 'qr/\18/';
+        pass("qr/\18/ didn't loop");
     }
 
 # New tests above this line, don't forget to update the test count below!
-BEGIN { plan tests => 19 }
+BEGIN { plan tests => 20 }
 # No tests here!
-- 
1.5.6.3

@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2010

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2010

From @cpansprout

On Tue Sep 28 13​:56​:09 2010, public@​khwilliamson.com wrote​:

The attached patch fixes this. Note that the circumstances when this
bug happened are if the first digit is any of [1-9], and the second
digit is [89]. I think it doesn't happen if the number of capture
groups is at least this two digit number.

Note that qr/\88/ means qr/\00088/. I consider this a bug, but others
says it has to be this way for backward compatiblity.

Thank you. Applied as ca67da4.

@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2010

From [Unknown Contact. See original ticket]

On Tue Sep 28 13​:56​:09 2010, public@​khwilliamson.com wrote​:

The attached patch fixes this. Note that the circumstances when this
bug happened are if the first digit is any of [1-9], and the second
digit is [89]. I think it doesn't happen if the number of capture
groups is at least this two digit number.

Note that qr/\88/ means qr/\00088/. I consider this a bug, but others
says it has to be this way for backward compatiblity.

Thank you. Applied as ca67da4.

@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2010

@cpansprout - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant