[Python-Dev] I plan to push faulthandler into Python 3.3 in one week

Victor Stinner victor.stinner at haypocalc.com
Fri Mar 25 17:39:30 CET 2011


Le jeudi 24 mars 2011 à 00:49 +0100, Victor Stinner a écrit :
> If nobody complains, I plan to push my faulthandler module into Python
> 3.3 in one week. It's a module to display the Python backtrace on a
> segfault, on a user signal or after a timeout.

I created a feature repo to prepare the work, features/faulthandler, and
the integration is done. You can try it, or try the last patch attached
to #11393.

I choose to add faulthandler as a builtin module to be able to control
exactly when it is initialized/finalized.

You can enable it at startup using -X faulthandler=1 or
PYTHONFAULTHANDLER=1 env var.

Example:
--------------
$ ./python -X faulthandler Lib/test/crashers/borrowed_ref_2.py 
hi
Fatal Python error: Segmentation fault

Traceback (most recent call first):
  File "Lib/test/crashers/borrowed_ref_2.py", line 18 in __set__
  File "Lib/test/crashers/borrowed_ref_2.py", line 36 in <module>
Erreur de segmentation
--------------

Try Lib/test/crashers/recursive_call.py if you would like to try the
stack overflow feature: faulthandler is able to dump the traceback, even
after a stack overflow. But only if sigaltstack() is available (e.g. not
on Windows, sorry).

faulthandler can also dump the traceback explicitly, after a timeout, or
on a user signal: it is not specific to segmentation faults ;-)

Victor



More information about the Python-Dev mailing list