Open
Description
Feature or enhancement
Proposal:
The faulthandler
module allows registering a SIGSEGV
handler to print a Python stacktrace if the program encounters a segfault. However, if developing C/C++ extension modules that may not be particularly useful on its own, and you also want the the C stacktrace.
The suggested API would be a kwarg to faulthandler.enable().
Implementation could use https://github.com/timmaxw/cfaulthandler as a starting point, timmaxw/cfaulthandler@561dbdd in particular.
The availability/usability of the feature would likely depend on platform and/or compile flags.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/print-c-stacktrace-with-faulthandler/56834
where @gpshead approved of opening a feature request
Linked PRs
- gh-127604: Add C stack dumps to
faulthandler
#128159 - gh-127604: Don't rely on
dprintf()
for faulthandler C stacks #132800 - gh-127604: Fix refleak in faulthandler_dump_c_stack_py() #132840
- gh-127604: Allow faulthandler to dumpC stack on MacOS #132841
- gh-127604: Replace dprintf() with _Py_write_noraise() #132854
- gh-127604: Only define dump_pointer() if CAN_C_BACKTRACE #132897
- gh-127604: ensure
-ldl
is passed to the linker whendladdr1
is found #133040 - gh-127604: ensure
-ldl
is passed only once to the linker #133071 - gh-127604: Optimize -ldl usage on platforms that use dlopen for libFFI. #133081