summaryrefslogtreecommitdiffstats
path: root/Tools/tsan
Commit message (Collapse)AuthorAgeFilesLines
* gh-117657: Fix file descriptor race in test_socket.py (#123697)Nadeshiko Manju2024-09-061-2/+0
|
* gh-117657: Avoid race in `PAUSE_ADAPTIVE_COUNTER` in free-threaded build ↵Sam Gross2024-07-301-1/+0
| | | | | | | (#122190) The adaptive counter doesn't do anything currently in the free-threaded build and TSan reports a data race due to concurrent modifications to the counter.
* gh-122201: Lock mutex when setting handling_thread to NULL (#122204)Sam Gross2024-07-261-1/+0
| | | | | In the free-threaded build, we need to lock pending->mutex when clearing the handling_thread in order not to race with a concurrent make_pending_calls in the same interpreter.
* gh-117657: Remove TSAN suppressions for _abc.c (#121508)Sam Gross2024-07-101-2/+0
| | | | The functions look thread-safe and I haven't seen any warnings issued when running the tests locally.
* gh-117657: Fix TSan race in _PyDict_CheckConsistency (#121551)Sam Gross2024-07-101-8/+0
| | | | The only remaining race in dictobject.c was in _PyDict_CheckConsistency when the dictionary has shared keys.
* gh-117657: Fix TSAN races in setobject.c (#121511)Sam Gross2024-07-091-3/+0
| | | | | The `used` field must be written using atomic stores because `set_len` and iterators may access the field concurrently without holding the per-object lock.
* gh-117657: Fix data races reported by TSAN in some set methods (#120914)AN Long2024-07-011-1/+0
| | | | | | Refactor the fast Unicode hash check into `_PyObject_HashFast` and use relaxed atomic loads in the free-threaded build. After this change, the TSAN doesn't report data races for this method.
* gh-117657: Use critical section to make _socket.socket.close thread safe ↵AN Long2024-07-011-1/+0
| | | | (GH-120490)
* gh-117657: Fix `__slots__` thread safety in free-threaded build (#119368)Daniele Parmeggiani2024-06-171-2/+0
| | | | Fix a race in `PyMember_GetOne` and `PyMember_SetOne` for `Py_T_OBJECT_EX`. These functions implement `__slots__` accesses for Python objects.
* gh-117657: Fix TSan reported data race on ioctl_works (#120175)Sam Gross2024-06-171-1/+0
|
* gh-117657: Add TSAN suppression for set_default_allocator_unlocked (#120500)AN Long2024-06-141-0/+2
| | | Add TSAN suppression for set_default_allocator_unlocked
* gh-117657: Make PyType_HasFeature atomic (GH-120210)Ken Jin2024-06-131-1/+0
| | | Make PyType_HasFeature atomic
* gh-117657: Make Py_TYPE and Py_SET_TYPE thread safe (GH-120165)Ken Jin2024-06-121-2/+0
| | | | Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
* gh-117657: Fix TSAN race involving import lock (#118523)Sam Gross2024-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.
* gh-117657: Fix race involving GC and heap initialization (#119923)Sam Gross2024-06-041-3/+0
| | | | | | | | | | | | 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`.
* gh-117657: Fix race involving immortalizing objects (#119927)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.
* gh-117657: Avoid `sem_clockwait` in TSAN (#119915)Sam Gross2024-06-031-9/+0
| | | | The `sem_clockwait` function is not currently instrumented, which leads to false positives.
* gh-117657: Fix data races report by TSAN unicode-hash (gh-119907)Donghee Na2024-06-031-1/+0
|
* gh-117657: Fix TSAN reported race in `_PyEval_IsGILEnabled`. (#119921)Sam Gross2024-06-021-1/+0
| | | | The GIL may be disabled concurrently with this call so we need to use a relaxed atomic load.
* gh-117657: Add TSAN suppression for `set_discard_entry` (#119908)Sam Gross2024-06-011-0/+2
| | | Seen in CI occasionally when running `test_weakref`.
* gh-117657: Fix TSAN race in QSBR assertion (#119887)Sam Gross2024-06-011-2/+0
| | | | Due to a limitation in TSAN, all reads from `PyThreadState.state` must be atomic to avoid reported races.
* gh-117657: Fix TSAN race in free-threaded GC (#119883)Sam Gross2024-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`.
* gh-117657: Fix itertools.count thread safety (#119268)Arnon Yaari2024-05-211-1/+0
| | | Fix itertools.count in free-threading mode
* gh-117657: Log TSAN warnings to separate files and archive them (#118747)mpage2024-05-101-0/+3
| | | | | | | 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.
* gh-117657: Fix QSBR race condition (#118843)Alex Turner2024-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.
* gh-117657: Fix data races reported by TSAN on `interp->threads.main` (#118865)mpage2024-05-101-2/+0
| | | Use relaxed loads/stores when reading/writing to this field.
* gh-117657: Replace TSAN suppresions with more specific rules (#118722)Brett Simmers2024-05-091-24/+81
| | | | | | | | | 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.
* gh-117657: Fix data races when writing / reading `ob_gc_bits` (#118292)mpage2024-05-081-3/+0
| | | | | 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.
* 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