faulthandler

Display the Python backtrace on a crash
Download

faulthandler Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Publisher Name:
  • Victor Stinner

faulthandler Tags


faulthandler Description

Display the Python backtrace on a crash faulthandler is a module for SIGSEGV, SIGFPE, SIGBUS and SIGILL signals to display the Python backtrace and restore the previous handler. Allocate an alternate stack for this handler, if sigaltstack() is available, to be able to allocate memory on the stack, even on stack overflow.Import the module and call faulthandler.enable() to enable the fault handler.The Python backtrace is written to the file descriptor 2 which is supposed to be the standard error stream. Start your graphical applications in a terminal and run your server in foreground to see the backtrace.Website: https://github.com/haypo/faulthandler/wiki/Example:Example of a segmentation fault on Linux: python>>> import faulthandler>>> faulthandler.enable()>>> faulthandler.sigsegv()Fatal Python error: Segmentation faultTraceback (most recent call first): File "< stdin >", line 1 in < module >Segmentation faultInstallation:To install faulthandler module, type the following command:python setup.py installThen you can test your setup using the following command:python tests.pyYou need a C compiler (eg. gcc) and Python headers to build the faulthandler module. Eg. on Fedora, you have to install python-devel package (sudo yum install python-devel).faulthandler module APIFault handler state (disabled by default): * enable(): enable the fault handler * disable(): disable the fault handler * isenabled(): get the status of the fault handlerFunctions to test the fault handler: * sigbus(): raise a SIGBUS signal (Bus error) * sigfpe(): raise a SIGFPE signal (Floating point exception), do a division by zero * sigill(): raise a SIGILL signal (Illegal instruction) * sigsegv(): raise a SIGSEGV signal (Segmentation fault), read memory from NULL (address 0)sigbus() and sigill() are not available on all operation systems.The version can be read in the "version" attribute: use "version >> 8" to get the major version, and "version & 255" to get the minor version. Requirements: · Python What's New in This Release: · Add register() and unregister() functions · Add optional all_threads argument to enable() · Limit the backtrace to 100 threads · Allocate an alternative stack for the fatal signal handler to be able to display a backtrace on a stack overflow (define HAVE_SIGALTSTACK). on Windows.


faulthandler Related Software