FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-154923: Serialize Tcl interpreter creation in _tkinter by bhuvi27 · Pull Request #156342 · python/cpython · GitHub

/ cpython Public

gh-154923: Serialize Tcl interpreter creation in _tkinter - #156342

Open
bhuvi27 wants to merge 2 commits into
python:mainfrom
bhuvi27:gh-154923-fix-tkinter-create-race
Open

gh-154923: Serialize Tcl interpreter creation in _tkinter#156342
bhuvi27 wants to merge 2 commits into
python:mainfrom
bhuvi27:gh-154923-fix-tkinter-create-race

Conversation

bhuvi27 commented Aug 25, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Fixes #154923

On the free-threaded build, concurrent _tkinter.create() calls raced Tcl's first-time library initialization (a TSan data race on a lazily created Tcl mutex) and could also double-free the module-global tcl_lock.

Serialize Tcl_CreateInterp() and the one-time tcl_lock free behind a dedicated mutex. tcl_lock itself cannot be used for this because it is discarded once Tcl is threaded. Add a subprocess regression test so the first CreateInterp has not already run.

This does not touch the event_tstate path in #153020.

Concurrent _tkinter.create() raced Tcl's first-time library init and
could double-free tcl_lock on the free-threaded build.
The c-globals checker rejects non-constant module-level globals, but
allows local static mutexes used to wrap non-thread-safe C APIs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data race creating Tcl interpreters concurrently via _tkinter.create under free-threading

1 participant


Back | FazBrowse Home | New Git URL