-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Deletion of autoTSSkey during runtime finalization is not safe #131185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Making it a thread-local sounds reasonable, but I think we also need to deal with My other concern (which might be an issue regardless of |
No, the thread state gets deleted: Line 3057 in ca7fd81
But I'm not really sure it matters because:
|
I'm thinking about embedders that don't necessarily exit after |
) Switches over to a _Py_thread_local in place of autoTssKey, and also fixes a few other checks regarding PyGILState_Ensure after finalization. Note that this doesn't fix concurrent use of PyGILState_Ensure with Py_Finalize; I'm pretty sure zapthreads doesn't work at all, and that needs to be fixed seperately.
The broader issue of unprotected runtime state at finalization is handled in gh-134307. |
Thanks for tackling this, @ZeroIntensity! |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
The
autoTssKey
is deleted during_PyRuntimeState_Fini
bygilstate_tss_fini
. This isn't safe because other threads may try callingPyGILState_Ensure()
orPyGILState_GetThisThreadState()
concurrently during shutdown.cpython/Python/pystate.c
Lines 486 to 501 in e9d210b
We can:
autoTssKey
to a_Py_thread_local
like_Py_tss_tstate
, which doesn't require deletionautoTssKey
at runtime finalizationMy preference is for the first option.
cc @ZeroIntensity @ericsnowcurrently @gpshead
Linked PRs
The text was updated successfully, but these errors were encountered: