develooper Front page | perl.perl5.porters | Postings from May 2003

[perl #22182] regular expression bug (design limitation?)

Thread Previous | Thread Next
From:
perlbug-followup
Date:
May 13, 2003 08:26
Subject:
[perl #22182] regular expression bug (design limitation?)
Message ID:
rt-22182-57503.4.74090743325135@bugs6.perl.org
# New Ticket Created by  esp5@mdss03.comp.pge.com 
# Please include the string:  [perl #22182]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22182 >



This is a bug report for perl from esp5@mdss03.comp.pge.com,
generated with the help of perlbug 1.34 running under perl v5.8.0.


-----------------------------------------------------------------
[Please enter your report here]

The following script dumps core on both perl-5.8.0 and perl-5.6.1 - it's probably
due to a design limitation in the regular expression engine, and I'm interested to
hear any workarounds.


---
script
---
$_singlestring = q$(?>\'(?>[^\\\']+|\\\.)*\')$;
my $_parens = "(?>\\s*\\((?>$_singlestring|(?>[^'\\(\\)]*))+\\))";

my $a = '(' . "'asdfasdf'" x 300000 . ')';

if ($a =~ m"($_parens)") { print STDERR "HERE"; }
---


Before dying, it gets the following trace:

#0  breakit () at regexec.c:4330
#1  0x000dcb1c in S_reginclass (n=0x16cc20, 
    p=0xf66064 "''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf"..., lenp=0x0, do_utf8=0 '\0') at regexec.c:4338
#2  0x000db984 in S_regrepeat (p=0x16cc20, max=2147483647) at regexec.c:4052
#3  0x000da87c in S_regmatch (prog=0x16cc20) at regexec.c:3707
#4  0x000db174 in S_regmatch (prog=0x16cc10) at regexec.c:3847
#5  0x000d8af8 in S_regmatch (prog=0x16cc64) at regexec.c:3214
#6  0x000d8af8 in S_regmatch (prog=0x16cc64) at regexec.c:3214
#7  0x000d8434 in S_regmatch (prog=0x16cc08) at regexec.c:3049
#8  0x000db174 in S_regmatch (prog=0x16cbf8) at regexec.c:3847
#9  0x000db174 in S_regmatch (prog=0x16cbec) at regexec.c:3847
#10 0x000d8af8 in S_regmatch (prog=0x16ccc8) at regexec.c:3214
#11 0x000d8af8 in S_regmatch (prog=0x16ccc8) at regexec.c:3214
#12 0x000d8af8 in S_regmatch (prog=0x16ccc8) at regexec.c:3214
#13 0x000d8af8 in S_regmatch (prog=0x16ccc8) at regexec.c:3214
#14 0x000d8af8 in S_regmatch (prog=0x16ccc8) at regexec.c:3214
#15 0x000d8af8 in S_regmatch (prog=0x16ccc8) at regexec.c:3214
#16 0x000d8af8 in S_regmatch (prog=0x16ccc8) at regexec.c:3214
...
#17570 0x000d8af8 in S_regmatch (prog=0x16ccc8) at regexec.c:3214
#17571 0x000d5fa0 in S_regtry (prog=0x16cb80,
    startpos=0xf3b288 "('asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf"...) at regexec.c:2145
	#17572 0x000d59dc in Perl_regexec_flags (prog=0x16cb80,
	    stringarg=0xf3b288 "('asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf"..., strend=0x1217949 ")",
		    strbeg=0xf3b288 "('asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf''asdfasdf"..., minend=15970952, sv=0x163ed4, data=0x0,
    flags=3) at regexec.c:1973
#17573 0x000841f4 in Perl_pp_match () at pp_hot.c:1291
#17574 0x0006dfbc in Perl_runops_debug () at dump.c:1398
#17575 0x00027ad4 in S_run_body (oldscope=1) at perl.c:1681

which seems to indicate to me that each time a $_singlestring is matched, perl calls
S_regmatch recursively. After too many S_regmatch stack levels happen, gcc gets confused 
and it dumps core.


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.8.0:

Configured by esp5 at Mon May 12 15:29:52 PDT 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris
    uname='sunos mdss03 5.8 generic_108528-15 sun4u sparc sunw,sun-fire-880 '
    config_args='-ds -e -Dprefix=/export/home/esp5/install/debug -Dcc=/home/esp5/install/bin/gcc -Dccflags= -g'
    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='/home/esp5/install/bin/gcc', ccflags ='-g -g -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DLEAKTEST -DDEBUGGING',
    optimize='-O',
    cppflags='-g -fno-strict-aliasing'
    ccversion='', gccversion='3.2.2', gccosandvers='solaris2.8'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    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='/home/esp5/install/bin/gcc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldbm -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.8.0:
    /export/home/esp5/install/debug/lib/perl5/5.8.0/sun4-solaris
    /export/home/esp5/install/debug/lib/perl5/5.8.0
    /export/home/esp5/install/debug/lib/perl5/site_perl/5.8.0/sun4-solaris
    /export/home/esp5/install/debug/lib/perl5/site_perl/5.8.0
    /export/home/esp5/install/debug/lib/perl5/site_perl
    .

---
Environment for perl v5.8.0:
    HOME=/home/esp5
    LANG (unset)
    LANGUAGE (unset)
    LC_COLLATE=en_US.ISO8859-1
    LC_CTYPE=en_US.ISO8859-1
    LC_MESSAGES=C
    LC_MONETARY=en_US.ISO8859-1
    LC_NUMERIC=en_US.ISO8859-1
    LC_TIME=en_US.ISO8859-1
    LD_LIBRARY_PATH=/opt/work/install/lib:/home/esp5/install/lib
    LOGDIR (unset)
    PATH=/home/esp5/install/bin:/opt/work/install/bin:/opt/oracle/817/bin:/opt/install/bin:/usr/ccs/bin:/usr/local/bin:/opt/SUNWspro/bin:/bin:/usr/bin:/usr/ucb:/etc:.:/usr/sbin:/usr/etc:/usr/openwin/bin:/usr/lib/lp/postscript:/export/home/dehc/x3270-3.1.1
    PERL_BADLANG (unset)
    PERL_PREFIX=/home/esp5/install
    SHELL=tcsh


Thread Previous | 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