Reputation: 3582
I have a unit test (using Check) that is crashing. How do I generate a core dump so I can debug it?
$ make check
.
.
.
XXX.c:216:E:Core:test01XXX:0: (after this point) Received signal 11 (Segmentation fault)
(Line 216 is just the beginning of test01XXX, not an actual line of code)
I have tried ulimit -c unlimited
but there is no core file.
Edit: I don't think this is an issue with writing a core file in general or finding it on disk. From the same directory, I can kill -SEGV
a process and it will generate a core file:
$ ls core*
ls: cannot access core*: No such file or directory
$ cat crash.c
int main()
{
return *(int *)0;
}
$ gcc -o crash crash.c
$ ./crash
Segmentation fault (core dumped)
$ ls core*
core.121934
I think the issue is that Check traps the SIGSEGV, and I just need to configure it differently somehow.
Upvotes: 1
Views: 1809
Reputation: 67733
From the What is Check? section on the front page, it defaults to running tests "in a separate address space" (i.e., in a child process), so they can't damage the unit test framework itself.
However, No Fork Mode is provided for precisely this reason:
However, when you are trying to debug why the segmentation fault or other program error occurred, forking makes it difficult to use debugging tools
Set or export CK_FORK=no
while you're figuring out this crash.
If you find some test that should always give you a core on failure, you can control it programmatically with
srunner_set_fork_status (..., CK_NOFORK);
Upvotes: 1