The Wayback Machine - https://web.archive.org/web/20240109171312/https://github.com/python/cpython/issues/112536
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for thread sanitizer (TSAN) via --with-thread-sanitizer #112536

Open
Tracked by #108219
colesbury opened this issue Nov 29, 2023 · 2 comments
Open
Tracked by #108219

Add support for thread sanitizer (TSAN) via --with-thread-sanitizer #112536

colesbury opened this issue Nov 29, 2023 · 2 comments
Assignees
Labels
3.13 new features, bugs and security fixes topic-free-threading type-feature A feature request or enhancement

Comments

@colesbury
Copy link
Contributor

colesbury commented Nov 29, 2023

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

@samety
Copy link
Contributor

samety commented 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
Copy link
Contributor

samety commented Dec 17, 2023

Added --with-thread-sanitizer as 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 new features, bugs and security fixes topic-free-threading type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants