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
Data race on event_tstate in _tkinter.c under free-threading #153020
event_tstate in Modules/_tkinter.c is written without synchronization in EnableEventHook() (~line 3545) and read under tcl_lock in EventHook() (~line 3507). _tkinter declares Py_MOD_GIL_NOT_USED, so the GIL no longer serializes these accesses under --disable-gil.
A torn read of event_tstate hands ENTER_PYTHON / PyEval_RestoreThread a dangling or NULL thread state.
This is not specific to the free-threaded build: the hook uses the thread state of the thread which created the first Tcl interpreter, so it crashes if that thread has exited. #162581 makes the hook use the thread state of the thread which calls it, so event_tstate is no longer needed.
Activity
picnixz commentedon Jul 4, 2026
cc @serhiy-storchaka
pythongh-153020: Fix race condition on event_tstate in _tkinter
pythongh-153020: Add NEWS entry for _tkinter data race fix
pythongh-153020: Fix race condition on event_tstate in _tkinter
pythongh-153020: Add NEWS entry for _tkinter data race fix
serhiy-storchaka commentedon Nov 24, 2026
This is not specific to the free-threaded build: the hook uses the thread state of the thread which created the first Tcl interpreter, so it crashes if that thread has exited. #162581 makes the hook use the thread state of the thread which calls it, so
event_tstateis no longer needed.gh-153020: Fix the tkinter event hook with Tcl interpreters in other …
[3.15] gh-153020: Fix the tkinter event hook with Tcl interpreters in…
[3.14] gh-153020: Fix the tkinter event hook with Tcl interpreters in…