summaryrefslogtreecommitdiffstats
path: root/Tools/tsan
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-117657: Fix `__slots__` thread safety in free-threaded build ↵Miss Islington (bot)2024-06-171-2/+0
| | | | | | | | | (GH-119368) (#120655) Fix a race in `PyMember_GetOne` and `PyMember_SetOne` for `Py_T_OBJECT_EX`. These functions implement `__slots__` accesses for Python objects. (cherry picked from commit 362cd2680b45a36c3467b9721ff7fc0ceb338452) Co-authored-by: Daniele Parmeggiani <8658291+dpdani@users.noreply.github.com>
* [3.13] gh-117657: Fix TSan reported data race on ioctl_works (GH-120175) ↵Miss Islington (bot)2024-06-171-1/+0
| | | | | | | (#120654) (cherry picked from commit 460cc9e14e221c53c0038a847bfd411fe184ebf3) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-117657: Add TSAN suppression for set_default_allocator_unlocked ↵Miss Islington (bot)2024-06-141-0/+2
| | | | | | | | | | (GH-120500) (#120510) gh-117657: Add TSAN suppression for set_default_allocator_unlocked (GH-120500) Add TSAN suppression for set_default_allocator_unlocked (cherry picked from commit 2bacc2343c24c49292dea3461f6b7664fc2d33e2) Co-authored-by: AN Long <aisk@users.noreply.github.com>
* [3.13] gh-117657: Make PyType_HasFeature atomic (GH-120210) (#120443)Miss Islington (bot)2024-06-131-1/+0
| | | | | | | | gh-117657: Make PyType_HasFeature atomic (GH-120210) Make PyType_HasFeature atomic (cherry picked from commit eebae2c460dabdc70dc0d9b6e189368eb1abb716) Co-authored-by: Ken Jin <kenjin@python.org>
* [3.13] gh-117657: Make Py_TYPE and Py_SET_TYPE thread safe (GH-120165) ↵Miss Islington (bot)2024-06-121-2/+0
| | | | | | | | | | (GH-120403) gh-117657: Make Py_TYPE and Py_SET_TYPE thread safe (GH-120165) (cherry picked from commit e16aed63f64b18a26859eff3de976ded373e66b8) Co-authored-by: Ken Jin <kenjin@python.org> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
* [3.13] gh-117657: Fix TSAN race involving import lock (GH-118523) (#120169)Miss Islington (bot)2024-06-061-4/+0
| | | | | | | | This adds a `_PyRecursiveMutex` type based on `PyMutex` and uses that for the import lock. This fixes some data races in the free-threaded build and generally simplifies the import lock code. (cherry picked from commit e21057b99967eb5323320e6d1121955e0cd2985e) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-117657: Fix race involving GC and heap initialization (GH-119923) ↵Miss Islington (bot)2024-06-041-3/+0
| | | | | | | | | | | | | | | | | (#120038) The `_PyThreadState_Bind()` function is called before the first `PyEval_AcquireThread()` so it's not synchronized with the stop the world GC. We had a race where `gc_visit_heaps()` might visit a thread's heap while it's being initialized. Use a simple atomic int to avoid visiting heaps for threads that are not yet fully initialized (i.e., before `tstate_mimalloc_bind()` is called). The race was reproducible by running: `python Lib/test/test_importlib/partial/pool_in_threads.py`. (cherry picked from commit e69d068ad0bd6a25434ea476a647b635da4d82bb) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-117657: Fix itertools.count thread safety (GH-119268) (#120007)Sam Gross2024-06-031-1/+0
| | | | | | Fix itertools.count in free-threading mode (cherry picked from commit 87939bd5790accea77c5a81093f16f28d3f0b429) Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
* [3.13] gh-117657: Fix race involving immortalizing objects (GH-119927) (#120005)Sam Gross2024-06-031-2/+0
| | | | | | | | | | | The free-threaded build currently immortalizes objects that use deferred reference counting (see gh-117783). This typically happens once the first non-main thread is created, but the behavior can be suppressed for tests, in subinterpreters, or during a compile() call. This fixes a race condition involving the tracking of whether the behavior is suppressed. (cherry picked from commit 47fb4327b5c405da6df066dcaa01b7c1aefab313)
* [3.13] gh-117657: Avoid `sem_clockwait` in TSAN (GH-119915) (#119992)Miss Islington (bot)2024-06-031-9/+0
| | | | | | | The `sem_clockwait` function is not currently instrumented, which leads to false positives. (cherry picked from commit 41c1cefbae71d687d1a935233b086473df65e15c) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-117657: Fix data races report by TSAN unicode-hash (gh-119907) ↵Miss Islington (bot)2024-06-031-1/+0
| | | | | | | | (gh-119963) gh-117657: Fix data races report by TSAN unicode-hash (gh-119907) (cherry picked from commit 0594a27e5f1d87d59fa8a761dd8ca9df4e42816d) Co-authored-by: Donghee Na <donghee.na@python.org>
* [3.13] gh-117657: Fix TSAN reported race in `_PyEval_IsGILEnabled`. ↵Miss Islington (bot)2024-06-021-1/+0
| | | | | | | | | (GH-119921) (#119939) The GIL may be disabled concurrently with this call so we need to use a relaxed atomic load. (cherry picked from commit f3b89a63cbb6d46e5ed40d5cd9813cdf9189ce35) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-117657: Add TSAN suppression for `set_discard_entry` (GH-119908) ↵Miss Islington (bot)2024-06-011-0/+2
| | | | | | | | (#119914) Seen in CI occasionally when running `test_weakref`. (cherry picked from commit 7dc745d1f5d9558047a52cad5e01df7567533269) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-117657: Fix TSAN race in QSBR assertion (GH-119887) (#119904)Miss Islington (bot)2024-06-011-2/+0
| | | | | | | Due to a limitation in TSAN, all reads from `PyThreadState.state` must be atomic to avoid reported races. (cherry picked from commit 90ec19fd33e2452902b9788d4821f1fbf6542304) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-117657: Fix TSAN race in free-threaded GC (GH-119883) (#119903)Miss Islington (bot)2024-06-011-3/+0
| | | | | | | | Only call `gc_restore_tid()` from stop-the-world contexts. `worklist_pop()` can be called while other threads are running, so use a relaxed atomic to modify `ob_tid`. (cherry picked from commit 60593b2052ca275559c11028d50e19f8e5dfee13) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-117657: Log TSAN warnings to separate files and archive them ↵Miss Islington (bot)2024-05-101-0/+3
| | | | | | | | | | | | (GH-118747) (#118931) This ensures we don't lose races that occur in subprocesses or interleave races from workers running in parallel. Log files are collected and packaged into a zipfile that can be downloaded from the "Artifacts" section of the workflow run. (cherry picked from commit b88889e9ffd7b2d2bdac75aecbf14e37fd68e337) Co-authored-by: mpage <mpage@meta.com>
* [3.13] gh-117657: Fix QSBR race condition (GH-118843) (#118905)Miss Islington (bot)2024-05-101-1/+0
| | | | | | | | | `_Py_qsbr_unregister` is called when the PyThreadState is already detached, so the access to `tstate->qsbr` isn't safe without locking the shared mutex. Grab the `struct _qsbr_shared` from the interpreter instead. (cherry picked from commit 33d20199af65c741bdc908a968edd8dc179b6974) Co-authored-by: Alex Turner <alexturner@meta.com>
* [3.13] gh-117657: Fix data races reported by TSAN on `interp->threads.main` ↵Miss Islington (bot)2024-05-101-2/+0
| | | | | | | | (GH-118865) (#118904) Use relaxed loads/stores when reading/writing to this field. (cherry picked from commit 22d5185308f85efa22ec1e8251c409fe1cbd9e6b) Co-authored-by: mpage <mpage@meta.com>
* [3.13] gh-117657: Replace TSAN suppresions with more specific rules ↵Miss Islington (bot)2024-05-091-24/+81
| | | | | | | | | | | | | | (GH-118722) (#118870) Using `race:` filters out warnings if the function appears anywhere in the stack trace. This can hide a lot of unrelated warnings, especially for a function like `_PyEval_EvalFrameDefault`, which is somewhere on the stack more often than not. Change all free-threaded suppressions to `race_top:`, which only matches the top frame, and add any new suppressions this exposes. (cherry picked from commit 98ff3f65c0232f31df89ebb52b244625ec9e3eb6) Co-authored-by: Brett Simmers <swtaarrs@users.noreply.github.com>
* [3.13] gh-117657: Fix data races when writing / reading `ob_gc_bits` ↵Miss Islington (bot)2024-05-081-3/+0
| | | | | | | | | | (GH-118292) (#118796) Use relaxed atomics when reading / writing to the field. There are still a few places in the GC where we do not use atomics. Those should be safe as the world is stopped. (cherry picked from commit cb6f75a32ca2649c6cc1cabb0301eb783efbd55b) Co-authored-by: mpage <mpage@meta.com>
* gh-117657: Disable the function/code cache in free-threaded builds (#118301)mpage2024-05-031-1/+0
| | | | This is only used by the specializing interpreter and the tier 2 optimizer, both of which are disabled in free-threaded builds.
* gh-117657: TSAN fix race on `gstate->young.count` (#118313)Alex Turner2024-04-291-1/+0
|
* gh-117657: Fix race data race in `_Py_IsOwnedByCurrentThread()` (#118258)mpage2024-04-261-1/+0
|
* gh-117657: Fixes a few small TSAN issues in dictobject (#118200)Dino Viehland2024-04-251-3/+0
| | | | Fixup TSAN errors for dict
* gh-117657: Add a couple more TSAN suppressions (#118256)mpage2024-04-251-0/+5
|
* gh-117657: Fix data race in `_Py_IsImmortal` (#118261)mpage2024-04-251-1/+0
| | | | The load of `ob_ref_local races with stores. Using a relaxed load is sufficient; stores to the field are relaxed.
* gh-117657: use relaxed loads for checking dict keys immortality (#118067)Dino Viehland2024-04-191-2/+0
| | | Use relaxed load to check if dictkeys are immortal
* gh-117657: Quiet erroneous TSAN reports of data races in `_PySeqLock` (#117955)mpage2024-04-171-2/+0
| | | | | | | | Quiet erroneous TSAN reports of data races in `_PySeqLock` TSAN reports a couple of data races between the compare/exchange in `_PySeqLock_LockWrite` and the non-atomic loads in `_PySeqLock_{Abandon,Unlock}Write`. This is another instance of TSAN incorrectly modeling failed compare/exchange as a write instead of a load.
* gh-117657: Fix data races in the method cache in free-threaded builds (#117954)mpage2024-04-171-1/+0
| | | | | | | | | Fix data races in the method cache in free-threaded builds These are technically data races, but I think they're benign (to the extent that that is actually possible). We update cache entries non-atomically but read them atomically from another thread, and there's nothing that establishes a happens-before relationship between the reads and writes that I can see.
* gh-117657: Add TSAN suppressions for the free-threaded build (#117736)mpage2024-04-152-3/+53
| | | | | Additionally, reduce the iterations for a few weakref tests that would otherwise take a prohibitively long amount of time (> 1 hour) when TSAN is enabled and the GIL is disabled.
* gh-112536: Add --tsan test for reasonable TSAN execution times. (gh-116601)Donghee Na2024-03-151-0/+5