Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
TheautoTssKey is deleted during_PyRuntimeState_Fini bygilstate_tss_fini. This isn't safe because other threads may try callingPyGILState_Ensure() orPyGILState_GetThisThreadState() concurrently during shutdown.
Lines 486 to 501 ine9d210b
| void | |
| _PyRuntimeState_Fini(_PyRuntimeState*runtime) | |
| { | |
| #ifdefPy_REF_DEBUG | |
| /* The count is cleared by _Py_FinalizeRefTotal(). */ | |
| assert(runtime->object_state.interpreter_leaks==0); | |
| #endif | |
| if (gilstate_tss_initialized(runtime)) { | |
| gilstate_tss_fini(runtime); | |
| } | |
| if (PyThread_tss_is_created(&runtime->trashTSSkey)) { | |
| PyThread_tss_delete(&runtime->trashTSSkey); | |
| } | |
| } |
We can:
- Convert
autoTssKeyto a_Py_thread_locallike_Py_tss_tstate, which doesn't require deletion - Don't delete
autoTssKeyat runtime finalization
My preference is for the first option.
cc@ZeroIntensity@ericsnowcurrently@gpshead