[issue8863] Display Python backtrace on SIGSEGV, SIGFPE and fatal error

STINNER Victor report at bugs.python.org
Sat Dec 18 01:54:11 CET 2010


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

Version 9 of my patch:
 - Create PYTHONNOHANDLER environment variable: don't install the signal handler if the variable is set
 - Rename "Segfault" by "FaultHandler"
 - reverse_string() does nothing if len==0, even if it cannot occur when it's called by dump_decimal() and dump_hexadecimal().
 - _Py_DumpBacktrace() only writes the first 100 frames (arbitrary limit) to avoid unlimited loops

I don't know 100 frames is a good limit or not. Is it enough?

Summary of the patch:
 - Add a fault handler for SIGSEGV, SIGFPE, SIGBUS and SIGILL signals: display the Python backtrace and abort the process (call the debugger on Windows)
 - Add PYTHONNOHANDLER environment variable to disable the fault handler
 - The fault handler is implemented using only very simple instructions: it calls only signal-safe functions and it doesn't allocate memory (on the heap, only some bytes on the stack)
 - The fault handler uses an alternate stack to be able to display the backtrace (to be able to allocate memory on the stack and call functions)

The fault handler has no more the infinite loop issue (because the backtrace is truncated on frame loop).

----------
Added file: http://bugs.python.org/file20102/segfault_handler-9.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8863>
_______________________________________


More information about the Python-bugs-list mailing list