[compiler-rt] [TSan] Destroy ScopedReport on early return in ReportDestroyLocked (PR #228631)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 18:39:52 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>

#<!-- -->151495 converted ScopedReport in ReportDestroyLocked from a stack
variable to placement new on __builtin_alloca storage, but left a bare
return when RestoreStack fails. This skipped ~ScopedReport(), leaking
ReportDesc and leaving ScopedErrorReportLock, report_mtx, and
ScopedIgnoreInterceptors permanently held.

Call rep->~ScopedReport() before returning when RestoreStack fails.

Assisted-by: Gemini


---
Full diff: https://github.com/llvm/llvm-project/pull/228631.diff


1 Files Affected:

- (modified) compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp (+3-1) 


``````````diff
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
index 30f5e964939d03..7210168af22c3d 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
@@ -604,8 +604,10 @@ void ReportDestroyLocked(ThreadState *thr, uptr pc, uptr addr,
     DynamicMutexSet mset;
     uptr tag;
     if (!RestoreStack(EventType::kLock, last_lock.sid(), last_lock.epoch(),
-                      addr, 0, kAccessWrite, &tid, &trace, mset, &tag))
+                      addr, 0, kAccessWrite, &tid, &trace, mset, &tag)) {
+      rep->~ScopedReport();
       return;
+    }
     rep->AddStack(trace, true);
     rep->AddLocation(addr, 1);
 #if SANITIZER_APPLE

``````````

</details>


https://github.com/llvm/llvm-project/pull/228631


More information about the llvm-commits mailing list