1#!perl 2BEGIN { 3 chdir 't' if -d 't'; 4 @INC = "../lib"; 5} 6 7use strict; 8require './test.pl'; 9use Config qw(%Config); 10 11# memory usage checked with top 12$ENV{PERL_TEST_MEMORY} >= 2 13 or skip_all("Need ~2GB for this test"); 14$Config{ptrsize} >= 8 15 or skip_all("Need 64-bit pointers for this test"); 16 17plan(tests => 4); 18 19my $space = " "; # avoid constant folding from doubling memory usage 20# concatenation here increases memory usage significantly 21my $work = $space x 0x80000002; 22substr($work, 0x80000000) = "\n\n"; 23 24# this would SEGV 25is(index($work, "\n"), 0x80000000, "test index() over 2G mark"); 26 27# this would simply fail 28is(rindex($work, "\n"), 0x80000001, "test rindex() over 2G mark"); 29 30utf8::upgrade($work); 31 32# this would SEGV 33is(index($work, "\n"), 0x80000000, "test index() over 2G mark (utf8-ish)"); 34 35# this would simply fail 36is(rindex($work, "\n"), 0x80000001, "test rindex() over 2G mark (utf8-ish)"); 37 38