diff options
author | Tony Cook <tony@develop-help.com> | 2014-04-15 03:57:57 +0200 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2014-05-28 14:12:16 +1000 |
commit | b464e2b7c8addfdd9b22b9a5949a89db7c73e43c (patch) | |
tree | 361d58bdc390a437304b2ed56cc2abf37af3b3a7 /t/bigmem | |
parent | ae07d0f95d9614b1ffea793b6ac5f2ffa324cb44 (diff) | |
download | perl-b464e2b7c8addfdd9b22b9a5949a89db7c73e43c.tar.gz |
fix the I32 bug for index() and rindex()
Diffstat (limited to 't/bigmem')
-rw-r--r-- | t/bigmem/index.t | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/t/bigmem/index.t b/t/bigmem/index.t new file mode 100644 index 0000000000..fdd502c7c7 --- /dev/null +++ b/t/bigmem/index.t @@ -0,0 +1,37 @@ +#!perl +BEGIN { + chdir 't'; + unshift @INC, "../lib"; +} + +use strict; +require './test.pl'; +use Config qw(%Config); + +# memory usage checked with top +$ENV{PERL_TEST_MEMORY} >= 2 + or skip_all("Need ~2GB for this test"); +$Config{ptrsize} >= 8 + or skip_all("Need 64-bit pointers for this test"); + +plan(tests => 4); + +my $space = " "; # avoid constant folding from doubling memory usage +# concatenation here increases memory usage significantly +my $work = $space x 0x80000002; +substr($work, 0x80000000) = "\n\n"; + +# this would SEGV +is(index($work, "\n"), 0x80000000, "test index() over 2G mark"); + +# this would simply fail +is(rindex($work, "\n"), 0x80000001, "test rindex() over 2G mark"); + +utf8::upgrade($work); + +# this would SEGV +is(index($work, "\n"), 0x80000000, "test index() over 2G mark (utf8-ish)"); + +# this would simply fail +is(rindex($work, "\n"), 0x80000001, "test rindex() over 2G mark (utf8-ish)"); + |