You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PyThreadState_Clear() should only be called from the same interpreter #112723
* current_fast_get()->interp must match tstate->interp
* for the main interpreter, current_fast_get() must be the main thread
*/
We should enforce this, particularly the comment about the matching interpreters. Calling PyThreadState_Clear() from the "wrong" interpreter is unsafe because if any of the PyObjects on the tstate are not NULL, calling their destructors from the wrong thread can lead to memory corruption.
This is also important for the "free threaded" builds because they have free lists associated with the PyThreadState and these will be cleared in PyThreadState_Clear() -- doing this in the wrong interpreter leads to memory corruption.
There are currently two places which call PyThreadState_Clear() from the "wrong" interpreter:
interp_create() in _xxsubinterpretersmodule.c. This is pretty easy to fix by setting the thread state before calling clear. `
Activity
pythongh-112723: Call `PyThreadState_Clear()` from the correct interp…
gh-112723: Call `PyThreadState_Clear()` from the correct interpreter (#…
pythongh-112723: Call `PyThreadState_Clear()` from the correct interp…
pythongh-112723: Call `PyThreadState_Clear()` from the correct interp…