If you follow perl5-porters, you'll know this already, but I think this deserves all the exposure it can.

Long-time perl users might be aware that perl's regular expression engine is a recursive implementation. This usually work ok, except on rather pathological cases where so much recursion takes place that the C stack runs out of space and the process dies with a segmentation fault.

perl -le '$x = "o" x shift; $x =~ s/(o?)+//g' 10000 # Bus error: 10 (core dumped)

(if the above doesn't crash for you, just up the 10000 a bit).

Just last week, dave_the_m checked a patch into the perl source code repository that converts the algorithm used from recursive to iterative. Since then steve_p has been busily going through the bug database, closing out dozens of bugs that have been corrected due to this change. All in all it's a stunning piece of work, and Dave deserves to be congratulated for it.

The code is now in blead. Once it's settled a while, it may be backported to the maintenance track, and it will start to appear in the 5.8 series. Otherwise you'll have to wait until 5.10.

Read Dave's announcement.

• another intruder with the mooring in the heart of the Perl


In reply to The perl regular expression engine is now iterative rather than recursive by grinder

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.