The dist/Storable/stacksize tool probes for recursion limits for
Storable, in an attempt to prevent stack overflows, and causes
segfaults when the probes exceed the available stack size.
This was leaving a core file for each failure (whether that ended
up as a single file or one for each segfault depended on the
system settings).
Try to probe for the ulimit -c option and if it doesn't cause an
error, prefix the command used to probe for recursion limits.
Ideally I could use setrlimit() for this, but we don't expose it in
core, nor in POSIX.pm, and adding it wouldn't help for the older
perls that Storable needs to build for.
if (is_miniperl()) {
die "Should not run during miniperl\n";
}
+my $prefix = "";
if ($^O eq "MSWin32") {
# prevent Windows popping up a dialog each time we overflow
# the stack
Win32API::File->import(qw(SetErrorMode SEM_NOGPFAULTERRORBOX SEM_FAILCRITICALERRORS));
SetErrorMode(SEM_NOGPFAULTERRORBOX() | SEM_FAILCRITICALERRORS());
}
+# the ; here is to ensure system() passes this to the shell
+elsif (system("ulimit -c 0 ;") == 0) {
+ # try to prevent core dumps
+ $prefix = "ulimit -c 0 ; ";
+}
if (@ARGV and $ARGV[0] eq '--core') {
$ENV{PERL_CORE} = 1;
}
my $code = "my \$t; \$Storable::$limit_name = -1; $try for 1..$i;dclone(\$t);";
my $q = ($^O eq 'MSWin32') ? '"' : "'";
- "$PERL $mblib -MStorable=dclone -e$q$code$q"
+ "$prefix $PERL $mblib -MStorable=dclone -e$q$code$q"
}
# try more
sub good {