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 in pyport.h)
- Move the definition of
_Py_NO_SANITIZE_THREAD from obmalloc.c to a place that's more widely available (like pyport.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
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.
--with-thread-sanitizeras a configure option_Py_THREAD_SANITIZERif thread-sanitizer is enabled (see, e.g.,_Py_ADDRESS_SANITIZERinpyport.h)_Py_NO_SANITIZE_THREADfromobmalloc.cto a place that's more widely available (likepyport.h). We're going to need this in a few placesEventually, 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
_Py_THREAD_SANITIZERon GCC when TSan is enabled #117702_Py_THREAD_SANITIZERon GCC when TSan is enabled (GH-117702) #117713