[Python-Dev] Issue #8863 adds a new?PYTHONNOFAULTHANDLER?environment variable (original) (raw)

Victor Stinner vstinner at edenwall.com
Thu Dec 23 03:26:35 CET 2010


Le lundi 20 décembre 2010 à 13:09 -0500, Alexander Belopolsky a écrit :

What if the program crashes (again) in the signal handler before having a chance to restore registers?

If the fault handler crashs, the registers are not restored.

Also, can you point to documentation that describes register restoring behavior?

I found an article telling that the kernel saves integer and float registers when calling a signal handler, but I am unable to find it again, sorry. And I cannot find an article telling the opposite.

Anyway, it would just be horrible if a signal handler was responsible to save/restore integer registers. If the kernel doesn't do that for us, I suppose that the compiler or something else does it for us.

Eg. signal_default_int_handler(), the Python handler of SIGINT signal, doesn't save/restore registers, even if it erases many of them.

Because I had actual experience with that using R. Your code may be better, but R brings up a dialog on segfault asking ...

You cannot compare a simple handler using simple signal-safe functions like write(), and a complex handler calling graphical functions. It is not safe to call graphical functions in a signal handler.

(I actually use RPy which loads R into Python as a shared library, so the two handlers will conflict anyways.)

It depends if R handler calls the previous handler. My fault handler is "chained" with the previous handler (it calls indirectly the previous handler). If R fault handler does the same, all handlers will be executed correctly (I don't think that the execution order matter).

Victor



More information about the Python-Dev mailing list