> [amc@arwen.cs.berkeley.edu - Tue Nov 09 12:08:10 1999]: > > > ----------------------------------------------------------------- > [Please enter your report here] > > The following program demonstrates a regular expression match on > a long string causing a SIGSEGV: > > #!/usr/bin/perl > $s = 'x'; > for ($i = 1; $i < 16; ++$i) { > $s = $s . $s; > print length($s), "\n"; > $s =~ /(a?x)*/; > } > > After the length of $s reaches 32768, perl crashes. I tried getting a > stack trace from gdb, but the stack appeared to be extremely large, so > maybe the problem is that the stack is overflowing. Should that cause > a > SIGSEGV, or should it be handled more gracefully? > > Is in necessary for that regular expression to require stack space > proportional to the size of the matched string? (It's been too long > since I took a compilers class.) > > By the way, the regular expression is a greatly simplified version of > one I was actually using to remove a prefix from a string and print > it. > The original code was structured like this: > > if ($s =~ s/^((a?x)+)//) { print $1 } > > My workaround is structured like this: > > while ($s =~ s/^((a?x){1,999})//) { print $1 } > It appears that as of change #27598, this no longer core dumps. davem++ :)