[compiler-rt] [TSan] Fix spurious 'thread finished with ignores enabled' warning on FreeBSD (PR #155399)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 26 04:59:37 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Dan Blackwell (DanBlackwell)
<details>
<summary>Changes</summary>
This fixes a false positive error report on FreeBSD under certain circumstances. The error occurs in the thr_exit interceptor as follows:
* `SCOPED_TSAN_INTERCEPTOR` macro calls the `ScopedInterceptor` constructor -> `EnableIgnores` -> `EnableIgnoresImpl`, which increments `thr_->suppress_reports`.
* `DestroyThreadState` -> `ThreadFinish` -> `ReportIgnoresEnabled` then fires off a warning, as `thr_->suppress_reports` is non-zero.
To avoid this spurious error, we follow the example of the `pthread_exit` interceptor, and take an anonymous scope so that the `ScopedInterceptor` destructor gets called before `DestroyThreadState`, decrementing `suppress_reports` back to 0.
---
Full diff: https://github.com/llvm/llvm-project/pull/155399.diff
1 Files Affected:
- (modified) compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp (+3-1)
``````````diff
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index b46a81031258c..8bb872f0148a9 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -2890,7 +2890,9 @@ TSAN_INTERCEPTOR(void, _lwp_exit) {
#if SANITIZER_FREEBSD
TSAN_INTERCEPTOR(void, thr_exit, ThreadID *state) {
- SCOPED_TSAN_INTERCEPTOR(thr_exit, state);
+ {
+ SCOPED_TSAN_INTERCEPTOR(thr_exit, state);
+ }
DestroyThreadState();
REAL(thr_exit(state));
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/155399
More information about the llvm-commits
mailing list