Page MenuHomeFreeBSD

Provide some more information for userland core dumps
ClosedPublic

Authored by emaste on May 2 2023, 10:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 4, 3:53 PM
Unknown Object (File)
Oct 4 2024, 4:57 AM
Unknown Object (File)
Oct 3 2024, 12:55 PM
Unknown Object (File)
Oct 3 2024, 10:56 AM
Unknown Object (File)
Sep 28 2024, 12:54 PM
Unknown Object (File)
Sep 27 2024, 1:11 AM
Unknown Object (File)
Sep 19 2024, 6:04 AM
Unknown Object (File)
Sep 12 2024, 6:23 PM
Subscribers

Details

Summary
Previously the log message indicated only "(core dumped)" if a core was
successfully created, or nothing if it was not. This provides
insufficient information to faciliate debugging. Dtrace is no help as
coredump() is static and we cannot find the return value via fbt.
Expand the log message to include error return value information.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste created this revision.

I did this in 2017 when trying to track down why a core dump failed and it's just been sitting around. Discussed with @jhb on IRC. John suggested adding an SDT probe for the return value in the default case which seems like a useful addition but could be a followup.

Why not print the numeric error code. 'other error' is also not too informative.

Dtrace is no help as coredump() is static and we cannot find the return value via fbt.

@christos' work gets us a large part of the way there now - you can at least trace coredump()'s entry and return: dtrace -n 'kinst::coredump:entry {printf("%s", curthread->td_name);} kinst::coredump:return {}' prints

0  73091                      sigexit:137 cat
1  73093                      sigexit:390

if I send SIGQUIT to cat. What doesn't work yet is getting the return value, but it's possible to access arbitrary registers from the probe context, so it's "just" a matter of knowing which one.

In any case, I think this change is useful.

sys/kern/kern_sig.c
3628

Handle ENOSYS as well?

3643

Add a break here?

The raw errno value would require a stack buffer to hold the formatted string which is my guess as to why it's just "other error" (and the original version Ed had didn't have the other error text even). I think if the other error case can be figured out via dtrace that using a static string to avoid the stack buffer is an ok compromise.

Is there any reason not to commit this?

sys/kern/kern_sig.c
3639

I believe coredump() will return ENOTCAPABLE if the program is in capability mode and kern.capmode_coredump=0. It would be useful to have a case here for that, with an error message that points users at the sysctl.

I would definitely like this committed.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 5 2023, 11:19 PM
This revision was automatically updated to reflect the committed changes.