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

Scott Dial scott+python-dev at scottdial.com
Sun Dec 19 23:08:51 CET 2010

On 12/18/2010 8:50 AM, James Y Knight wrote:
> I think instead of calling abort() to kill the process, you should:
> - install the signal handler with SA_NODEFER|SA_RESETHAND (or if
> sigaction is not present, explicitly reset the action to SIG_DFL and
> unblock first thing upon entering the handler), and then,
> - at the end of the handler, kill(getpid(), orig_signal) in order to
> abort the process.

I concur with this being the correct way to right such a handler.

> This has two advantages: 1) the process's exit code will actually 
> show the correct signal,

It's more than an advantage: it's the only correct way to handle a
termination signal.

> 2) it might let the OS fault handlers work properly
> as well -- I'm not sure. If it does, you may want to experiment with
> whether having or omitting SA_NODEFER gives a better backtrace (from the
> OS mechanism) in that case.

Even if that doesn't work, things like the grsecurity patches to linux
use these signals to detect exploits and log them and do throttling.
Calling abort() effectively converts all of these faults into SIGABRT
terminations that are considered (more?) innocent terminations.

Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu

Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu

More information about the Python-Dev mailing list