summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-03-07 15:22:49 +0000
committerDavid Mitchell <davem@iabyn.com>2017-03-15 09:19:54 +0000
commita7dd840b16566dcdb761159060e3f05d9ed57073 (patch)
tree29bcb3e79f81cb7fcb9bc02ff828c860f950eca7
parent00195859c65eccf9425faf45db543a12c7ad3874 (diff)
downloadperl-a7dd840b16566dcdb761159060e3f05d9ed57073.tar.gz
add range.t test for RT #130841
-rw-r--r--t/op/range.t33
1 files changed, 31 insertions, 2 deletions
diff --git a/t/op/range.t b/t/op/range.t
index e58a39c8e8..02a38e0497 100644
--- a/t/op/range.t
+++ b/t/op/range.t
@@ -9,7 +9,7 @@ BEGIN {
use Config;
-plan (145);
+plan (146);
is(join(':',1..5), '1:2:3:4:5');
@@ -417,4 +417,33 @@ is( ( join ' ', map { join '', map ++$_, 'a'..'d' } 1..2 ), 'bcde bcde',
$s = ''; for (1..2) { for ('a'..'d') { $s .= ++$_ } $s.=' ' if $_==1; }
is( $s, 'bcde bcde','modifiable alpha counting loop counter' );
-# EOF
+# RT #130841
+# generating an extreme range triggered a croak, which if caught,
+# left the temps stack small but with a very large PL_tmps_max
+
+fresh_perl_like(<<'EOF', qr/\Aok 1 ok 2\Z/, {}, "RT #130841");
+my $max_iv = (~0 >> 1);
+eval {
+ my @range = 1..($max_iv - 1);
+};
+if ($@ =~ /panic: memory wrap|Out of memory/) {
+ print "ok 1";
+}
+else {
+ print "unexpected err status: [$@]";
+}
+
+# create and push lots of temps
+my $max = 10_000;
+my @ints = map $_+1, 0..($max-1);
+my $sum = 0;
+$sum += $_ for @ints;
+my $exp = $max*($max+1)/2;
+if ($sum == $exp) {
+ print " ok 2";
+}
+else {
+ print " unexpected sum: [$sum]; expected: [$exp]";
+}
+EOF
+