On Dec 17, 2010, at 7:55 PM, Victor Stinner wrote:

> Hi,
> 
> In 2008, I proposed a patch to raise a Python exception on SIGSEVG signal. In 
> some cases, it's possible to catch the exception, log it, and continue the 
> execution. But because in some cases, the Python internal state is corrupted, 
> the idea was rejected (see the issue #3999).
> 
> Someone asked me to display the Python backtrace on SIGSEGV, instead of 
> raising an exception. I implemented this idea in issue #8863. After 9 
> versions, I think that the patch is ready for inclusion. It catchs SIGSEGV, 
> SIGFPE, SIGBUS and SIGILL signals, and also display the Python backtrace on 
> fatal errors. Because some operating systems have their own fault handler 
> (eg. Ubuntu with apport), Dave Malcolm asked me to add an option disable the 
> Python handler. 

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.

This has two advantages: 1) the process's exit code will actually show the 
correct 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.

If #2 actually works, you may not even need the env var, which would be nice. 

James
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to