-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
The faulthandler module's code for printing stack traces is not thread-safe:
- That's mostly okay -- faulthandler is mostly triggered when something goes wrong, like a segfault or a deadlock/timeout, so best effort is acceptable.
- In free threaded Python, we don't print out stacktraces for all threads on a segfault, but we do print them on a timeout. That can lead to TSan reported data races on timeouts.
I think we want to keep the timeout behavior the same, which means living with some data races:
- It mostly works and is useful.
- There's no one "current thread" in a timeout. The "dump traceback later" thread (
faulthandler_thread) doesn't have a thread state / hold the GIL, so it's a different situation than on segfault, where the crashing thread's stacktrace is the most useful (and safest to access).
We also have some suppressions in suppressions_free_threading.txt, but these are out of date.
I think we should add _Py_NO_SANITIZE_THREAD to the relevant faulthandler.c functions so that TSan doesn't report data races when faulthandler is running.
Linked PRs
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error