Repository navigation
Make TSAN tests pass with the GIL disabled in free-threaded builds #117657
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Apr 8, 2024 - added 4 commits that reference this issue
on Apr 12, 2024 - added 5 commits that reference this issue
on Apr 17, 2024 275 remaining items
Load more actions- addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on Mar 22, 2025 - added a commit that references this issue
on Jul 8, 2025 Great work everyone, this was a big one!
Reacted by Gregory P. Smith and Daniele Parmeggiani
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Feature or enhancement
We need to make the TSAN tests pass with the GIL disabled before we can disable the GIL by default in free-threaded builds.
This should proceed in two phases:
How to run the TSAN tests
env CC=clang CXX=clang++ ./configure --disable-gil --with-thread-sanitizer --with-pydebug && make -jenv TSAN_OPTIONS=suppressions=<repo_root>/Tools/tsan/suppressions_free_threading.txt ./python -m test --tsan -j4Working on a race
<repo_root>/Tools/tsan/suppressions_free_threading.txt, run the TSAN tests, and verify that the race is reported by TSAN. You may need to comment out unrelated functions (notably,_PyEval_EvalFrameDefault) in order to reproduce the race.Suppressions
Linked PRs
start_the_world()andtstate_try_attach()#117828_PySeqLock#117955tstate->state#118165_Py_IsOwnedByCurrentThread()#118258_Py_IsImmortal#118261ob_gc_bits#118292ob_gc_bits(GH-118292) #118796SemLock.__{enter,exit}__#118812SemLock.__{enter,exit}__(GH-118812) #118856interp->threads.main#118865interp->threads.main(GH-118865) #118904PyMember_GetandPyMember_Set, forPy_T_OBJECT_EXtype #119368set_discard_entry#119908set_discard_entry(GH-119908) #119914sem_clockwaitin TSAN #119915_PyEval_IsGILEnabled. #119921_PyEval_IsGILEnabled. (GH-119921) #119939sem_clockwaitin TSAN (GH-119915) #119992__slots__thread safety in free-threaded build (GH-119368) #120655PAUSE_ADAPTIVE_COUNTERin free-threaded build #122190PAUSE_ADAPTIVE_COUNTERin free-threaded build (GH-122190) #122475PyMember_GetandPyMember_Set, for C extensions #123211dict_dict_merge#129755dict_dict_merge(gh-129755) #129808compare_unicode_unicode_threadsafe#131746test_capiunder TSAN #136269