Closed
Description
Feature or enhancement
GCC and Clang provide ThreadSanitizer, a tool that detects data races. We should add support for thread sanitizer to CPython. Note that Python already supports the memory and address sanitizers.
- Add
--with-thread-sanitizer
as a configure option - Define
_Py_THREAD_SANITIZER
if thread-sanitizer is enabled (see, e.g.,_Py_ADDRESS_SANITIZER
inpyport.h
) - Move the definition of
_Py_NO_SANITIZE_THREAD
fromobmalloc.c
to a place that's more widely available (likepyport.h
). We're going to need this in a few places
Eventually, it would be helpful to have a continuous build for the combination of --disable-gil --with-thread-sanitizer
. Note that we probably won't want to run all the tests. ThreadSanitizer is slow and also not very useful for single-threaded tests. We should collect a subset of our tests that use threading for the ThreadSanitizer continuous build.
Linked PRs
- gh-112536: Add support for thread sanitizer (TSAN) #112648
- gh-112536: enable tsan in build #113232
- gh-112536: Set up TSAN CI for free-threading #116555
- gh-112536: Define MI_TSAN to 1 for --with-mimalloc and --with-thread-sanitizer #116558
- gh-112536: Add --tsan test for reasonable TSAN execution times. #116601
- gh-112536: Add TSAN builds on Github Actions #116872
- gh-112536: Add more TSAN tests #116896
- gh-112536: Add test_threading to TSAN tests #116898
- GH-112536: Add more TSan tests #116911
- [3.12] gh-112536: Add support for thread sanitizer (TSAN) (gh-112648) #116924
- [3.11] gh-112536: Add support for thread sanitizer (TSAN) (gh-112648) #116926
- [3.12] gh-112536: Add --tsan test for reasonable TSAN execution times. (gh-116601) #116929
- [3.12] gh-112536: Add TSAN build on Github Actions (GH-116872) #116953
- gh-112536: Define
_Py_THREAD_SANITIZER
on GCC when TSan is enabled #117702 - [3.12] gh-112536: Define
_Py_THREAD_SANITIZER
on GCC when TSan is enabled (GH-117702) #117713 - [3.10]gh-112536: Add support for thread sanitizer (TSAN)(gh-112648) #123833