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

Segmentation fault caused by capturing regex #6861

Closed
p5pRT opened this issue Oct 22, 2003 · 4 comments
Closed

Segmentation fault caused by capturing regex #6861

p5pRT opened this issue Oct 22, 2003 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 22, 2003

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

Searchable as RT24271$

@p5pRT
Copy link
Author

p5pRT commented Oct 22, 2003

From pmiguel@purdue.edu

Created by pmiguel@purdue.edu

The following script generates a "Segmentation fault"​:

#!/usr/bin/perl -w
$_ = "12 24\n" x 3176;
/(\d+[\n ]+)*/g;

If "x 3176" is replaced with "x 3175" or any lower repetition there
is no Segmentation fault.

But the "x 3176" limit is specific to this machine. The same version of
perl running on a bigger Sun machine running SunOS 5.9 does not
segmentation fault until "x 3177". A Mac OSX cluster running perl, v5.6.0
gives a segmentation fault at "x 286".

The following script generates a "Segementation fault" on every machine I've
tried it on​:

#!/usr/bin/perl -w
for ($i=200; $i < 1000000; $i++) {
  $_ = "12 24\n" x $i;
  print $i, "\n";
  /(\d+[\n ]+)*/g;
}

Phillip SanMiguel

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.8.0:

Configured by babernat at Thu May 29 14:53:33 EST 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris-thread-multi
    uname='sunos silverjack 5.8 generic_108528-14 sun4u sparc sunw,ultra-4 '
    config_args='-des -Dcc=gcc -Dusethreads -Duselargefiles'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef 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='gcc', ccflags ='-D_REENTRANT -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-D_REENTRANT -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='gcc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lrt -lpthread -lc
    perllibs=-lsocket -lnsl -ldl -lm -lrt -lpthread -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:
    /usr/local/lib/perl5/5.8.0/sun4-solaris-thread-multi
    /usr/local/lib/perl5/5.8.0
    /usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris-thread-multi
    /usr/local/lib/perl5/site_perl/5.8.0
    /usr/local/lib/perl5/site_perl/5.7.2
    /usr/local/lib/perl5/site_perl/5.6.1
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.8.0:
    HOME=/home/pmiguel
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/dt/lib:/usr/local/staden_solaris/lib/solaris-binaries:/home/local/oracle/lib:/usr/lib/:/usr/local/lib:/usr/local/stackpack/lib:/usr/local/stackpack/lib.ext:/usr/gcg/gcgbin/oblib
    LOGDIR (unset)
    PATH=.:/home/pmiguel/bin:/home/pmiguel/bin:/usr/local/bin:/opt/SUNWspro/bin:/usr/bin:/usr/openwin/bin:/usr/local/tex/bin:/usr/ccs/bin:/usr/dt/bin:/usr/ucb:/usr/local/stackpack/bin:/usr/j2se/bin:/usr/local/stackpack/bin:/home/local/oracle/bin:/usr/local/staden_solaris/solaris-bin:/usr/local/stackpack/bin:/usr/gcg/gcgcore/script:/usr/gcg/gcgbin/execute
    PERL_BADLANG (unset)
    SHELL=/usr/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Oct 23, 2003

From @rspier

Phillip,

  Thanks for your report. This is a known issue in perl's regex
  engine related to it using the stack for recursion. You can make
  it stop crashing by increasing the stack size as limited by the
  operating system. Use limit or ulimit depending on the shell you
  are using.

  There are hopeful plans for this to be fixed in 5.10.

-R

At 22 Oct 2003 17​:32​:39 -0000,
pmiguel@​purdue.edu (via RT) wrote​:

The following script generates a "Segmentation fault"​:

#!/usr/bin/perl -w
$_ = "12 24\n" x 3176;
/(\d+[\n ]+)*/g;

If "x 3176" is replaced with "x 3175" or any lower repetition there
is no Segmentation fault.

@p5pRT
Copy link
Author

p5pRT commented Mar 29, 2006

From @smpeters

[pmiguel - Wed Oct 22 10​:32​:39 2003]​:

This is a bug report for perl from pmiguel@​purdue.edu,
generated with the help of perlbug 1.34 running under perl v5.8.0.

-----------------------------------------------------------------
[Please enter your report here]
The following script generates a "Segmentation fault"​:

#!/usr/bin/perl -w
$_ = "12 24\n" x 3176;
/(\d+[\n ]+)*/g;

If "x 3176" is replaced with "x 3175" or any lower repetition there
is no Segmentation fault.

But the "x 3176" limit is specific to this machine. The same version
of
perl running on a bigger Sun machine running SunOS 5.9 does not
segmentation fault until "x 3177". A Mac OSX cluster running perl,
v5.6.0
gives a segmentation fault at "x 286".

The following script generates a "Segementation fault" on every
machine I've
tried it on​:

#!/usr/bin/perl -w
for ($i=200; $i < 1000000; $i++) {
$_ = "12 24\n" x $i;
print $i, "\n";
/(\d+[\n ]+)*/g;
}

This has been fixed in bleadperl with change #27598.

@p5pRT p5pRT closed this as completed Mar 29, 2006
@p5pRT
Copy link
Author

p5pRT commented Mar 29, 2006

@smpeters - 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