This is pretty interesting. It worked fine with 5.6.1 and 5.8.0 on freebsd. It caused 5.8.2 to segfault on my debian box where 5.8.0 and 5.6.1 ran fine. It also crashed AS 5.8.2 whereas AS 5.6.1 ran fine under windows. Seems to be a 5.8.2 problem.

Also, increasing $MAX to 200 makes the problem go away with both.

Update: On 5.8.2 under debian, it segfaults for $MAX between 66 and 125 as well as between 254 and 354 (stopped testing at 400). On AS 5.8.2 it crashes for $MAX between 65 and 125. It also crashes with 255 and above (stopped testing at 275 since whenever it crashes, it brings up that window which I have to click). If you'd like to test it yourself, use the following:

#!/usr/bin/perl use strict; use warnings; my $MAX = shift; my $re = qr /^(1+)(??{"(?:$1){" . (length ($1) - 1) . "}" })$/; for (1 .. $MAX) {printf "%3d is a square\n" => $_ if (1 x $_) =~ /$re/} do {printf "%3d is a square\n" => $_ if (1 x $_) =~ /$re/} for 1 .. $ +MAX; map {printf "%3d is a square\n" => $_ if (1 x $_) =~ /$re/} 1 .. $ +MAX;

Windows:

perl -le "print $_,system(qq{perl script.pl $_ > dump.out})?' NOK':' o +k' for (1..275)"

*nix:

perl -le'print $_,$",system("perl script.pl $_ > /dev/null")?"NOK":"ok +" for (1..275)'

Update 2: I've compiled 5.6.2 and 5.9.0 and tested it on both. Surprisingly, it fails for $MAX set to 125. In fact, every version of perl I tested on every platform I tested failed when $MAX was set to 125. Odd.

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1


In reply to Re: Unexpected 'Out of Memory' by antirice
in thread Unexpected 'Out of Memory' by Abigail-II

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.