Open jkeenan opened 1 year ago
Why does this create a segfault file (./perl.core) on FreeBSD but not on Linux?
Probably because your FreeBSD has been set up to leave behind coredumps but your linux hasn't?
Why does this create a segfault file (./perl.core) on FreeBSD but not on Linux?
Probably because your FreeBSD has been set up to leave behind coredumps but your linux hasn't?
Thanks for getting back on this. I'm merely a user of this FreeBSD system, so I myself would not have done anything to "set up" or not "set up" to leave core dumps behind. In addition, I noted in https://github.com/Perl/perl5/issues/21455 that I've also observed the untracked perl.core
file in an OpenBSD VM that happens to sit on this FreeBSD server. That VM I simply downloaded from hashicorp, so I didn't consciously do anything to specify its core dump behavior there either.
So that suggests two questions:
t/harness.t
in my branch is that on Linux either no perl.core
is created or, if one is, it is immediately whisked away.)It appears that whether a perl.core
core dump file is created (and, hence, reported on by git status
) is indeed an OS-specific setting. From a Stack Exchange response:
The core dump is written in the current directory of the
process at the time of the crash.
Of course core dumps need to be enabled, by default those
are usually disabled. Check the output of ulimit -c,
if that's 0 then no core file will be written.
Run ulimit -c unlimited to enable core dumps;
this is a per-process setting which is inherited by
processes started by that process.
Linux: From man bash
:
ulimit [-HS] [-bcdefiklmnpqrstuvxPRT [limit]]
Provides control over the resources available
to the shell and to processes started
by it, on systems that allow such control.
...
-c The maximum size of core files created
FreeBSD: From man sh
:
ulimit [-HSabcdfklmnopstuvw] [limit]
Set or display resource limits (see getrlimit(2)).
If limit is specified, the named resource will
be set; otherwise the current
resource value will be displayed.
...
-c coredumpsize
The maximal size of core dump files, in
512-byte blocks. Setting coredumpsize to 0
prevents core dump files from being created.
ulimit
Settings to which I have access:
# Ubuntu Linux 22.04 LTS
$ uname -mrs; ulimit -c
Linux 6.2.0-32-generic x86_64
0
# Debian Bullseye
$ uname -mrs; ulimit -c
Linux 5.10.0-18-amd64 x86_64
0
# FreeBSD-13
$ uname -mrs; ulimit -c
FreeBSD 13.2-RELEASE-p1 amd64
unlimited
# OpenBSD-6.9
$ uname -mrs; ulimit -c
OpenBSD 6.9 amd64
unlimited
I myself have never fiddled with these system settings, so I assume that they are defaults for their respective OSes.
So my hunch is that before running a test which executes a segfault, we should check the system's value for ulimit -c
and, if that value is not 0
, set it to 0
for that process.
(I currently don't know how to do that, so if anyone else can jump in here with a patch for t/harness.t
, please do so.)
So my hunch is that before running a test which executes a segfault, we should check the system's value for ulimit -c and, if that value is not 0, set it to 0 for that process.
We can't. Or at least not without bringing in a XS module like BSD::Resource
Would anything like this code in Perl's dist/Storable/stacksize
be helpful?
41 # the ; here is to ensure system() passes this to the shell
42 elsif (system("ulimit -c 0 ;") == 0) {
43 # try to prevent core dumps
44 $prefix = "ulimit -c 0 ; ";
45 }
Would anything like this code in Perl's dist/Storable/stacksize be helpful?
No, not really. Not without some serious rearchitecting that wouldn't be proportional to the size of the issue.
Would anything like this code in Perl's dist/Storable/stacksize be helpful?
No, not really. Not without some serious rearchitecting that wouldn't be proportional to the size of the issue.
Well, my last thought on this is ... Could we simply skip the segfaut test if ulimit was not 0
on a given machine?
Would anything like this code in Perl's dist/Storable/stacksize be helpful?
No, not really. Not without some serious rearchitecting that wouldn't be proportional to the size of the issue.
Well, my last thought on this is ... Could we simply skip the segfaut test if ulimit was not
0
on a given machine?
Or, if nothing else will work, we should place a comment indicating that a perl.core
file will be left over if your machine is not a self-flushing toilet. :-)
This was presumably fixed in the repository by https://github.com/Perl-Toolchain-Gang/Test-Harness/commit/161ff77b3ec184b57ddafb3d4d19111016b260c0. However, it will need to be incorporated into a new CPAN release as well.
This ticket continues the discussion begun in the Perl issue tracker at https://github.com/Perl/perl5/issues/21455. I'm moving the discussion here because:
My analysis indicates that the problem lies in Test-Harness's own test suite and is merely reproduced when Test-Harness is synched into core; and
Test-Harness's documentation on CPAN indicates that bug tickets should be filed on RT, but that queue consists of 62 old reports and I suspect filing here in the Perl-Toolchain-Gang organization will get more attention. (If you want me to file on RT instead, just let me know.)
The discussion so far
Briefly, the discussion in https://github.com/Perl/perl5/issues/21455: For the last month, when I configure, build and test Perl on FreeBSD (and other OSes) and then call
git status
at the end of the test suite, the status output includes:This core dump does not cause any test failures and appears to be compiler-independent, but is nonetheless real:
I do not observe this core dump on Linux: neither by
ls
nor bygit status
.I haven't definitively bisected this problem to see when it entered the Perl 5 core distribution, but I strongly suspect that it occurred when I synched Test-Harness-3.46 into core on August 13.
I performed that synching on Linux. All tests passed.
git status
was clean, so I had no reason to repeat that process on any other OS. If I weren't regularly building and testing on FreeBSD-13, I wouldn't have stumbled across this problem. My expectation is that on any (non-Windows, at least) OS to which I have access, after I run perl'smake test_harness
, all tests should PASS andgit status
should show no untracked files.Research in the Test-Harness repository on GitHub
I brought my own fork of Test-Harness on GitHub up-to-date with PTC's repository, then created a branch so that I could isolate the code generating the segfault in a way by which I could compare Linux and FreeBSD output more precisely. That 'segfault-analysis-20230908' branch is here.
I acknowledge that I have rarely peered into Test-Harness's code; hence, there may be weaknesses in the diagnostic code I added in my branch. All my changes are confined to
t/harness.t
:All the changes are debugging code except splitting
_runtests( $harness_failures, "$sample_tests/segfault" );
into two separate invocations of_runtests()
, for the second of which I had to create a new TAP::Harness object.Results
If I build Test::Harness on each of Linux and FreeBSD and exercise the file generating the segfault on FreeBSD, I get these comparative results:
Ubuntu Linux 22.04 LTS at release-3.45_01-12-gffc5f49
FreeBSD-13 at release-3.45_01-12-gffc5f49
Note that only on FreeBSD do I get this statement in the output from my branch:
... and that a core dump is created only on FreeBSD, as shown from this line in
ls
:Inferences and Next Questions
t/sample-tests/segfault
:print "1..1\n"; print "ok 1\n"; kill 'SEGV', $$;