msg71862 - (view) |
Author: Daniel Diniz (ajaksu2) *  |
Date: 2008-08-24 20:39 |
The following crashes the interpreter on exit: import sys, atexit; atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0); sys.exit() Found with Fusil. |
|
|
msg71866 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2008-08-24 20:53 |
I'm getting hundreds of lines Fatal Python error: PyThreadState_Get: no current thread The Python process segfaults in call_ll_exitfuncs -> atexit_cleanup() -> atexit_clear() -> atexit_delete_cb -> Py_DECREF(cb->args) |
|
|
msg71872 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2008-08-24 21:10 |
I was able to trace the error to its apartment. During the cleanup gen_del calls PyErr_Fetch() which fails in PyThreadState_GET(). Conclusion: The atexit cleanup method must be called much earlier. call_ll_exitfunc() is too late. I suggest a new function that calls atexit_cleanup() right after atexit_callfuncs(). |
|
|
msg73376 - (view) |
Author: Skip Montanaro (skip.montanaro) *  |
Date: 2008-09-18 12:07 |
Why not just have atexit_callfuncs call atexit_cleanup at the end of its execution? |
|
|
msg73378 - (view) |
Author: Skip Montanaro (skip.montanaro) *  |
Date: 2008-09-18 12:21 |
The attached patch causes an exception to print at exit on my Mac: >>> import sys, atexit >>> atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0) <function at 0x5c91e0> >>> sys.exit() Error in atexit._run_exitfuncs: TypeError: print_exception(): Exception expected for value, str found Without the patch I get the same TypeError but it's followed by a Bus error. I don't know if the patch is right or wrong, better or worse than the status quo, but I'll toss it out there for consideration. It certainly seems to subscribe to Christian's theme of calling atexit_cleanup() earlier. |
|
|
msg73381 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2008-09-18 13:27 |
Skip: I suggest you move the cleanup call before PyErr_Restore(). The current code doesn't re-raise exception raised in the cleanup function. |
|
|
msg73384 - (view) |
Author: Skip Montanaro (skip.montanaro) *  |
Date: 2008-09-18 14:16 |
New patch. This also makes the various atexit_* functions static. |
|
|
msg73590 - (view) |
Author: Skip Montanaro (skip.montanaro) *  |
Date: 2008-09-22 19:45 |
I've taken this ticket. Can someone please review and give it a thumbs up or thumbs down? |
|
|
msg73591 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2008-09-22 20:11 |
*thumbs up* |
|
|
msg73610 - (view) |
Author: Skip Montanaro (skip.montanaro) *  |
Date: 2008-09-23 00:53 |
Checked in as revision 66562. |
|
|