Repository navigation
Closed
Labels
3.13only security fixesonly security fixesbuildThe build process and cross-buildThe build process and cross-buildtopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
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-sanitizeras a configure option - Define
_Py_THREAD_SANITIZERif thread-sanitizer is enabled (see, e.g.,_Py_ADDRESS_SANITIZERinpyport.h) - Move the definition of
_Py_NO_SANITIZE_THREADfromobmalloc.cto 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_SANITIZERon GCC when TSan is enabled #117702 - [3.12] gh-112536: Define
_Py_THREAD_SANITIZERon GCC when TSan is enabled (GH-117702) #117713 - [3.10]gh-112536: Add support for thread sanitizer (TSAN)(gh-112648) #123833
Reacted by Erlend E. Aasland, Kirill Podoprigora and Antoine Pitrou
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixesbuildThe build process and cross-buildThe build process and cross-buildtopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Activity
samety commentedon Dec 3, 2023
Hey,
I would like to pick this up.
As a first step tried copying the struct for ASAN to TSAN
Here is a draft PR: #112648
Happy to get some initial feedback on it and then add remaining things like _Py_THREAD_SANITIZER etc.
samety commentedon Dec 17, 2023
Added
--with-thread-sanitizeras a configure option in pr 112648.Still looking for a good way to enable TSAN for the continuous build, I will make another PR when I find one.
gh-112536: Add support for thread sanitizer (TSAN) (gh-112648)
pythongh-112536: Add support for thread sanitizer (TSAN) (pythongh-11…
pythongh-112536: Add support for thread sanitizer (TSAN) (pythongh-11…
pythongh-112536: Set up TSAN CI for free-threading
pythongh-112536: Define MI_TSAN to 1 for --with-mimalloc and --with-t…
Revert "pythongh-112536: Define MI_TSAN to 1 for --with-mimalloc and …
gh-112536: Define MI_TSAN to 1 for --with-mimalloc and --with-thread-…
pythongh-112536: Add --tsan test for reasonable TSAN execution times.
41 remaining items
pythonGH-112536: Add more TSan tests (python#116911)
pythongh-112536: Define `_Py_THREAD_SANITIZER` on GCC when TSan is en…
gh-112536: Define `_Py_THREAD_SANITIZER` on GCC when TSan is enabled (#…
pythongh-112536: Define `_Py_THREAD_SANITIZER` on GCC when TSan is en…
[3.12] gh-112536: Define `_Py_THREAD_SANITIZER` on GCC when TSan is e…
pythongh-112536: Define MI_TSAN to 1 for --with-mimalloc and --with-t…
pythongh-112536: Add --tsan test for reasonable TSAN execution times. (…
pythongh-112536: Add TSAN builds on Github Actions (python#116872)
pythongh-112536: Add test_threading to TSAN tests (python#116898)
pythongh-112536: Add more TSAN tests (python#116896)
pythonGH-112536: Add more TSan tests (python#116911)
pythongh-112536: Define `_Py_THREAD_SANITIZER` on GCC when TSan is en…
comicfans commentedon Aug 27, 2024
hello, possible to backport this to 3.10 too ?
pythongh-112536: Add support for thread sanitizer (TSAN) (pythongh-11…
picnixz commentedon Sep 8, 2024
Unfortunately, 3.8 to 3.11 are security-only branches. As such, they would not accept such backports. The 3.11 backport was not merged since it was close to the last bugfix deadline.