[New-bugs-announce] [issue36476] Runtime finalization assumes all other threads have exited.

Eric Snow report at bugs.python.org
Fri Mar 29 16:38:26 EDT 2019


New submission from Eric Snow <ericsnowcurrently at gmail.com>:

Among the first 3 things that happen in Py_FinalizeEx() are, in order:

1. wait for all non-daemon threads (of the main interpreter) to finish
2. call registered atexit funcs
3. mark the runtime as finalizing

At that point the only remaining Python threads are:

* the main thread (where finalization is happening)
* daemon threads
* non-daemon threads created in atexit functions
* any threads belonging to subinterpreters

The next time any of those threads (aside from main) acquire the GIL, we expect that they will exit via a call to PyThread_exit_thread() (caveat: issue #36475).  However, we have no guarantee on when that will happen, if ever.  Such lingering threads can cause problems, including crashes and deadlock (see issue #36469).

I don't know what else we can do, beyond what we're already doing.  Any ideas?

----------
components: Interpreter Core
messages: 339143
nosy: eric.snow
priority: normal
severity: normal
status: open
title: Runtime finalization assumes all other threads have exited.
type: behavior
versions: Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36476>
_______________________________________


More information about the New-bugs-announce mailing list