Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python.announce > #135

faulthandler 2.0

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <victor.stinner@haypocalc.com>
X-Original-To python-announce-list@python.org
Delivered-To python-announce-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'debug': 0.03; 'example:': 0.03; 'handler': 0.05; '===========': 0.07; 'e.g.,': 0.07; 'python': 0.07; 'url:pypi': 0.09; 'compiler.': 0.09; 'fatal': 0.09; 'flush': 0.09; 'unix,': 0.09; 'url:dev': 0.09; 'files.': 0.10; 'output': 0.12; 'error:': 0.14; 'crashes': 0.16; 'lucky,': 0.16; 'outline': 0.16; 'problem:': 0.16; 'received:212.27': 0.16; 'received:212.27.42': 0.16; 'received:212.27.42.2': 0.16; 'received:free.fr': 0.16; 'received:smtp2-g21.free.fr': 0.16; 'seconds,': 0.16; 'timeout': 0.16; 'traceback.': 0.16; 'zero,': 0.16; 'skip:" 40': 0.16; 'traceback': 0.16; 'developer': 0.16; 'url:blog': 0.18; 'situation.': 0.19; 'e.g.': 0.22; 'tools,': 0.22; 'posted': 0.22; 'division': 0.23; 'programs.': 0.26; 'environment': 0.26; 'unable': 0.26; 'error': 0.29; 'skip:" 30': 0.29; 'exit': 0.29; 'explicitly': 0.29; 'host': 0.30; 'operating': 0.30; 'url:library': 0.31; 'another': 0.32; 'example,': 0.33; 'option': 0.33; 'url:docs': 0.33; 'skip:= 10': 0.33; 'module': 0.33; 'sometimes': 0.33; 'using': 0.34; 'received:192': 0.34; 'received:192.168.0': 0.35; 'file': 0.35; 'fault': 0.35; 'skip:f 40': 0.35; 'error.': 0.36; 'feature': 0.36; 'possibility': 0.36; 'received:192.168': 0.37; 'should': 0.37; 'url:python': 0.37; 'helped': 0.38; 'skip:= 20': 0.38; 'thread': 0.38; 'to:addr :python-announce-list': 0.38; 'install': 0.38; 'user': 0.38; 'but': 0.38; 'url:org': 0.38; 'current': 0.38; 'help': 0.39; 'bus': 0.39; 'errors': 0.39; 'signal': 0.39; 'announce': 0.39; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'windows.': 0.40; 'tracking': 0.60; 'enable': 0.65; 'due': 0.67; 'race': 0.73; 'article': 0.75; '3.3': 0.84; 'fashion,': 0.84; 'fault,': 0.84; 'restart': 0.84; 'timer': 0.84; 'timer.': 0.84; 'url:05': 0.84; 'victor': 0.84; 'aka': 0.91; 'running,': 0.91; 'scenario': 0.91
Subject faulthandler 2.0
From Victor Stinner <victor.stinner@haypocalc.com>
To python-announce-list@python.org
Content-Type text/plain; charset="UTF-8"
Date Thu, 12 May 2011 23:02:40 +0200
Mime-Version 1.0
X-Mailer Evolution 2.32.3
Content-Transfer-Encoding 7bit
X-Mailman-Approved-At Sun, 15 May 2011 03:54:01 +0200
X-BeenThere python-announce-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To python-list@python.org
List-Id Announcement-only list for the Python programming language <python-announce-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-announce-list>, <mailto:python-announce-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-announce-list>
List-Post <mailto:python-announce-list@python.org>
List-Help <mailto:python-announce-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-announce-list>, <mailto:python-announce-list-request@python.org?subject=subscribe>
Approved python-announce-list@python.org
Newsgroups comp.lang.python.announce
Message-ID <mailman.1573.1305424443.9059.python-announce-list@python.org> (permalink)
Lines 88
NNTP-Posting-Host 82.94.164.166
X-Trace 1305424443 news.xs4all.nl 81479 [::ffff:82.94.164.166]:56150
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python.announce:135

Show key headers only | View raw


When a user reports that your program crashes or hangs, sometimes you
can only help to try and collect more information and outline a scenario
to reproduce the situation. Even with a reliable user scenario, as a
developer you are often unable to reproduce the situation due to
environment differences, e.g., operating system and compiler. If you are
lucky, the user will be able to install debug tools, but most of time
you will have to wait until another person is able to obtain more
information from the same situation.

This mail is adapted from the article posted on the Python Insider to
announce the introduction of the faulthandler module into Python 3.3:

http://blog.python.org/2011/05/new-faulthandler-module-in-python-33.html



Fatal Errors
============

The faulthandler module should help this problem:

    http://pypi.python.org/pypi/faulthandler/

faulthandler provides the ability to dump the Python traceback on a
fatal error such as a segmentation fault, division by zero, abort, or
bus error. You can enable it inside your application using
faulthandler.enable(). Output example:

    Fatal Python error: Segmentation fault

    Current thread 0x00007f7babc6b700:
      File "Lib/test/crashers/gc_inspection.py", line 29 in g
      File "Lib/test/crashers/gc_inspection.py", line 32 in <module>
    Segmentation fault


Timeout
=======

faulthandler can also dump the traceback after a timeout using
faulthandler.dump_tracebacks_later(timeout). Call it again to restart
the timer or call faulthandler.cancel_dump_tracebacks_later() to stop
the timer. Output example:

    Timeout (0:01:00)!
    Current thread 0x00007f987d459700:
      File "Lib/test/crashers/infinite_loop_re.py", line 20 in <module>

Use the repeat=True option to dump the traceback each timeout seconds,
or exit=True to immediatly exit the program in an unsafe fashion, e.g.
don't flush files.


User Signal
===========

If you have access to the host on which the program is running, you can
use faulthandler.register(signal) to install a signal handler to dump
the traceback when signal is received. On UNIX, for example, you can use
the SIGUSR1 signal: kill -USR1 <pid> will dump the current traceback.
This feature is not available on Windows. Output example:

    Current thread 0x00007fdc3da74700:
      File "Lib/test/crashers/infinite_loop_re.py", line 19 in <module>


Another possibility is to explicitly call faulthandler.dump_traceback()
in your program.


Integrated in Python 3.3
========================

faulthandler is now part of Python 3.3 and has a nice documentation:

    http://docs.python.org/dev/library/faulthandler.html


Early Success
=============

The new faulthandler module has already helped with tracking down race
conditions in Python buildbots. I hope that it will also help you in
your programs.


Victor Stinner aka haypo

Back to comp.lang.python.announce | Previous | Next | Find similar | Unroll thread


Thread

faulthandler 2.0 Victor Stinner <victor.stinner@haypocalc.com> - 2011-05-12 23:02 +0200

csiph-web