[llvm-branch-commits] [NFC][TSan] Remove unnecessary ThreadRegistryLock in signal and mutex-held reports (PR #228812)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Oct 3 20:15:24 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
Now that ScopedReport construction and AddStack do not require
ThreadRegistryLock, SignalUnsafeCall, ReportErrnoSpoiling, and
ReportMutexHeldWrongContext do not access thread_registry at all. Remove
the unnecessary ThreadRegistryLock scopes from these three functions.
Assisted-by: Gemini
---
Full diff: https://github.com/llvm/llvm-project/pull/228812.diff
3 Files Affected:
- (modified) compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp (+2-7)
- (modified) compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp (+4-9)
- (modified) compiler-rt/lib/tsan/rtl/tsan_mman.cpp (+1-6)
``````````diff
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index 4c0c39bb6cc8202..b0eb92fbd6a5077 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -2179,13 +2179,8 @@ static void ReportErrnoSpoiling(ThreadState *thr, uptr pc, int sig) {
if (IsFiredSuppression(ctx, ReportTypeErrnoInSignal, stack))
return;
ScopedReport rep(ReportTypeErrnoInSignal);
- // Release locks before symbolizing and outputting the report to avoid
- // deadlocks.
- {
- ThreadRegistryLock l(&ctx->thread_registry);
- rep.SetSigNum(sig);
- rep.AddStack(stack, true);
- }
+ rep.SetSigNum(sig);
+ rep.AddStack(stack, true);
OutputReport(thr, rep);
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp b/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
index 11311ce8e901f17..445e84c843237b4 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
@@ -444,16 +444,11 @@ static void ReportMutexHeldWrongContext(ThreadState *thr, uptr pc) {
VarSizeStackTrace trace;
ObtainCurrentStack(thr, pc, &trace);
ScopedReport rep(ReportTypeMutexHeldWrongContext);
- // Release locks before symbolizing and outputting the report to avoid
- // deadlocks.
- {
- ThreadRegistryLock l(&ctx->thread_registry);
- for (uptr i = 0; i < thr->mset.Size(); ++i) {
- MutexSet::Desc desc = thr->mset.Get(i);
- rep.AddMutex(desc.addr, desc.stack_id);
- }
- rep.AddStack(trace, true);
+ for (uptr i = 0; i < thr->mset.Size(); ++i) {
+ MutexSet::Desc desc = thr->mset.Get(i);
+ rep.AddMutex(desc.addr, desc.stack_id);
}
+ rep.AddStack(trace, true);
OutputReport(thr, rep);
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_mman.cpp b/compiler-rt/lib/tsan/rtl/tsan_mman.cpp
index 7a39b8a71a0a795..fda49d9fb8f428c 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_mman.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_mman.cpp
@@ -183,12 +183,7 @@ static void SignalUnsafeCall(ThreadState *thr, uptr pc) {
if (IsFiredSuppression(ctx, ReportTypeSignalUnsafe, stack))
return;
ScopedReport rep(ReportTypeSignalUnsafe);
- // Release locks before symbolizing and outputting the report to avoid
- // deadlocks.
- {
- ThreadRegistryLock l(&ctx->thread_registry);
- rep.AddStack(stack, true);
- }
+ rep.AddStack(stack, true);
OutputReport(thr, rep);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/228812
More information about the llvm-branch-commits
mailing list