GeezerVison is showing github.com — Make TSAN tests pass with the GIL disabled in free-threaded builds · Issue #117657 · python/cpython
Make TSAN tests pass with the GIL disabled in free-threaded builds #117657DescriptionFeature 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:
- Add suppressions for existing TSAN warnings.
- Triage, fix, and remove the suppressions for the warnings enumerated in (1).
How to run the TSAN tests
- Build with TSAN:
env CC=clang CXX=clang++ ./configure --disable-gil --with-thread-sanitizer --with-pydebug && make -j
- Run tests:
env TSAN_OPTIONS=suppressions=<repo_root>/Tools/tsan/suppressions_free_threading.txt ./python -m test --tsan -j4
Working on a race
- Verify that the TSAN tests are passing using the steps from above.
- Pick a suppression from the section below and assign it to yourself (edit it and add your username next to it). Some of them may be related. If you find that other suppressions are related to the race you're working on please assign them to yourself or contact their owner if they're already assigned.
- Delete the suppression from
<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.
- Fix the race.
Suppressions
### Tasks
- [ ] PyInterpreterState_ThreadHead
- [ ] PyThreadState_Clear
- [ ] PyThreadState_Next
- [ ] PyUnstable_InterpreterFrame_GetLine
- [ ] _PyFrame_GetCode
- [ ] _PyFrame_Initialize
- [ ] _PyObject_TryGetInstanceAttribute
- [ ] _Py_slot_tp_getattr_hook
- [x] _multiprocessing_SemLock_acquire_impl
- [x] _multiprocessing_SemLock_release_impl
- [ ] add_threadstate
- [ ] assign_version_tag
- [ ] dump_traceback
- [ ] fatal_error
- [ ] free_threadstate
- [ ] list_get_item_ref
- [x] new_reference
- [ ] pthread_create
- [ ] set_default_allocator_unlocked
- [ ] tstate_delete_common
- [ ] tstate_is_freed
- [ ] type_modified_unlocked
- [ ] write_thread_id
Linked PRs
Activityadded 4 commits that reference this issue on Apr 12, 2024gh-117657: Quiet TSAN warning about a data race between `start_the_wo… gh-117657: Quiet more TSAN warnings due to incorrect modeling of comp… added 5 commits that reference this issue on Apr 17, 2024gh-117657: Fix data races in the method cache in free-threaded builds (… gh-117657: Quiet erroneous TSAN reports of data races in `_PySeqLock` (… [gh-117657] _Py_MergeZeroLocalRefcount isn't loading ob_ref_shared wi… nascheme commented on Jan 7, 2026 Great work everyone, this was a big one! Reacted by Gregory P. Smith and Daniele Parmeggiani
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|