Crash Due to Exception in threading._shutdown() #113148
Labels
3.12
bugs and security fixes
3.13
bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
topic-subinterpreters
type-crash
A hard crash of the interpreter, possibly with a core dump
One of the first thing that happens during interpreter finalization is waiting for all non-daemon threads to finish. This is implemented by calling
threading._shutdown()
. If an exception is raised there (e.g. in athreading
"atexit" function), it gets ignored and we end up with non-daemon threads still running. In subinterpreters that results in a fatal error almost immediately after, since we make sure there's only one thread state left at that point.Reproducer:
The solution? Make sure
threading._shutdown()
finishes its fundamental job: stop all non-daemon threads and wait for them to finish. At the very least, this means ignoring exceptions from functions registered withthreading._register_atexit()
.The text was updated successfully, but these errors were encountered: