I have a small script which takes some html file as its input and strips out certain chunks of the html using a search and replace regexp prior to spitting it out.

Here's a larely reduced and simplified version of the script (done so as to narrow down to the actual buggy spot):
use strict; open(IN,"page.html"); $/ = undef; my $content = <IN>; close(IN); print "size: ". length($content) ."\n"; # either of the two regexp cause seg fault! # $content =~ s/^Set-Cookie: .*$//mgi; # CORE DUMP # Also trying to remove the /g option here. # Still core dumps. # $content =~ s/^Set-Cookie: .*$//mi; # CORE DUMP # these work fine though... $content =~ s/^Cache-Control: .*$//mi; # OK print "Done.\n";
Try uncommenting either of the two lines marked # CORE DUMP and the script will core dump.
----------------
size: 67877 Segmentation fault (core dumped)
I'm also puzzled over why the second CORE DUMP line still fails when I remove the /g regexp option? As I look at the OK line and compare it to the CORE DUMP line just above it (also without the /g option), I hardly note any startling difference.

This script would only core dump on a server where I have perl 5.6.0 installed. The same script works just fine with perl 5.6.1

Aware of any difference?

Thanks for help..

Update: Just played with the page.html file and added 'Set-Cookie: foobar' line and the script didn't core dump! So, it only does so when there are no 'Set-Cookie: .*' line in the source file. (note: there was a 'Cache-Control: .*' line there already.. I didn't try removing it to see if the script would then core dump, though)

"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith

In reply to Mystereous regexp core dump by vladb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.