diff options
author | Tony Cook <tony@develop-help.com> | 2018-03-22 11:48:29 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2018-04-02 11:28:14 +1000 |
commit | c8435d23822f81fcc007463002bb2ea843e008a0 (patch) | |
tree | d92f9a2515e098bc06427e086baf2ee7d0d40fac | |
parent | a438847a54e7c15139cf9830f29d770ebeaa7a3c (diff) | |
download | perl-c8435d23822f81fcc007463002bb2ea843e008a0.tar.gz |
(perl #133009) handle the XP fallback after we're ready to write
Also, check we can use Storable before trying to probe recursion
limits.
As bulk88 points out, Win32 may return 0 from system even if the
probe crashes, so instead have the probe output some text after the
recursion check and test that the text is output.
-rw-r--r-- | dist/Storable/stacksize | 36 | ||||
-rw-r--r-- | win32/GNUmakefile | 5 | ||||
-rw-r--r-- | win32/makefile.mk | 5 |
3 files changed, 31 insertions, 15 deletions
diff --git a/dist/Storable/stacksize b/dist/Storable/stacksize index 54cd947c53..7abd3a84cc 100644 --- a/dist/Storable/stacksize +++ b/dist/Storable/stacksize @@ -33,13 +33,6 @@ if (is_miniperl()) { } my $prefix = ""; if ($^O eq "MSWin32") { - require Win32; - my ($str, $major, $minor) = Win32::GetOSVersion(); - if ($major < 6 || $major == 6 && $minor < 1) { - print "Using defaults for older Win32\n"; - write_limits(500, 256); - exit; - } # prevent Windows popping up a dialog each time we overflow # the stack require Win32API::File; @@ -78,6 +71,15 @@ if ($ENV{PERL_CORE}) { -d "lib" or mkdir "lib"; -d "lib/Storable" or mkdir "lib/Storable"; +if ($^O eq "MSWin32") { + require Win32; + my ($str, $major, $minor) = Win32::GetOSVersion(); + if ($major < 6 || $major == 6 && $minor < 1) { + print "Using defaults for older Win32\n"; + write_limits(500, 256); + exit; + } +} my ($n, $good, $bad, $found) = (65000, 100, $bad1, undef); print "probe for max. stack sizes...\n" unless QUIET; @@ -102,7 +104,7 @@ if (PARALLEL) { sub cmd { my ($i, $try, $limit_name) = @_; die unless $i; - my $code = "my \$t; \$Storable::$limit_name = -1; $try for 1..$i;dclone(\$t);"; + my $code = "my \$t; \$Storable::$limit_name = -1; $try for 1..$i;dclone(\$t); print qq/ok\n/"; my $q = ($^O eq 'MSWin32') ? '"' : "'"; "$prefix $PERL $mblib -MStorable=dclone -e$q$code$q" @@ -131,14 +133,26 @@ sub bad { return $j; } +sub array_cmd { + my $depth = shift; + return cmd($depth, '$t=[$t]', 'recursion_limit'); +} + +# first check we can successfully run with a minimum level +my $cmd = array_cmd(1); +unless ((my $output = `$cmd`) =~ /\bok\b/) { + die "Cannot run probe: '$output', aborting...\n"; +} + unless ($ENV{STORABLE_NOISY}) { # suppress Segmentation fault messages open STDERR, ">", File::Spec->devnull; } + while (!$found) { - my $cmd = cmd($n, '$t=[$t]', 'recursion_limit'); + my $cmd = array_cmd($n); #print "$cmd\n" unless $QUIET; - if (system($cmd) == 0) { + if (`$cmd` =~ /\bok\b/) { $n = good($n); } else { $n = bad($n); @@ -158,7 +172,7 @@ $bad = $max if $bad > $max; while (!$found) { my $cmd = cmd($n, '$t={1=>$t}', 'recursion_limit_hash'); #print "$cmd\n" unless $QUIET; - if (system($cmd) == 0) { + if (`$cmd` =~ /\bok\b/) { $n = good($n); } else { $n = bad($n); diff --git a/win32/GNUmakefile b/win32/GNUmakefile index 1704126816..5e70d04560 100644 --- a/win32/GNUmakefile +++ b/win32/GNUmakefile @@ -1600,8 +1600,9 @@ Extensions_realclean : PostExt : ..\lib\Storable\Limit.pm # we need the exe, perl(ver).dll, and the Exporter, Storable, Win32 extensions -# rebasePE covers just about that, including adjustment for static builds -..\lib\Storable\Limit.pm : rebasePE +# rebasePE most of that, including adjustment for static builds, so we +# just need non-xs extensions +..\lib\Storable\Limit.pm : rebasePE Extensions_nonxs $(PLMAKE) -C ..\dist\Storable lib\Storable\Limit.pm if not exist ..\lib\Storable mkdir ..\lib\Storable copy ..\dist\Storable\lib\Storable\Limit.pm ..\lib\Storable\Limit.pm diff --git a/win32/makefile.mk b/win32/makefile.mk index ed250c720e..ff82a18472 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -1552,8 +1552,9 @@ PostExt : ..\lib\Storable\Limit.pm $(NOOP) # we need the exe, perl(ver).dll, and the Exporter, Storable, Win32 extensions -# rebasePE covers just about that, including adjustment for static builds -..\lib\Storable\Limit.pm : rebasePE +# rebasePE most of that, including adjustment for static builds, so we +# just need non-xs extensions +..\lib\Storable\Limit.pm : rebasePE Extensions_nonxs cd ..\dist\Storable && $(MAKE) lib\Storable\Limit.pm if not exist ..\lib\Storable mkdir ..\lib\Storable copy ..\dist\Storable\lib\Storable\Limit.pm ..\lib\Storable\Limit.pm |