[Python-Dev] Issue #8863 adds a new PYTHONNOFAULTHANDLER environment variable

Victor Stinner victor.stinner at haypocalc.com
Sun Dec 19 23:10:43 CET 2010

Le samedi 18 décembre 2010 à 17:23 +0100, Georg Brandl a écrit :
> Well, without a closer I assume that for some crashes it's just not
> possible anymore for the Python interpreter to even print out the
> traceback?

The worst case occurs if the frame objects are corrupted, eg. if the
filename of a frame is an invalid object (eg. pointer to NULL or to a
corrupted unicode object).

If the file descriptor 2 is not stderr (eg. if there is no file
descriptor 2), the backtrace cannot be printed.

Except of these two issues, I think that the fault handler is always
able to display the backtrace, even on stack overflow or invalid memory


Older versions of my patch were less reliable:

 - allocate memory on the heap => only use the stack (only few bytes)
 - call "complex" Python functions (like UTF-8 codec with
backslashreplace error handler) => use a very simple ASCII
+backslashreplace implementation and avoid complex functions
 - use not signal-safe functions like printf => use write() and simple
functions to format numbers
 - may go into an unlimited loop if there is a loop in the frame linked
list => limit the loop to MAX_DEPTH (100) iterations


More information about the Python-Dev mailing list