[Israel.pm] segmentation fault in regex
migo at homemail.com
Sun Mar 12 05:09:16 PST 2006
On 12 Mar 2006 14:06:37 +0200, Yossi.Itzkovich at ecitele.com wrote:
> The code:
> $file =~ s~/\*[^*]*\*+([^/*][^*]*\*+)*/|//[^\n]*|(\"(\\.|[^\"\\])*\"|'(\\.|[^'\\])*'|.[^/"'\\]*)~$2~gs;
> Any ideas ?
At a glance, this regexp may require a lot of memory (actually stack).
In the past I regularly got perl core dumps when requested unoptimal
regexps. I.e. you reach your process stack size limit and it gets killed.
There are 2 solutions:
1) Increase the process stack size. Depending on a shell it may be
"limit stacksize [unlimited]" or "ulimit -s [unlimited]". There is also
system-wide configuration, but this is OS dependent.
2) Rewrite your regexp. Possibly divide your file to smaller parts first.
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'
More information about the Perl