[compiler-rt] [compiler-rt][rtsan] Add scoped reporting lock (PR #107167)

Chris Apple via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 16:33:51 PDT 2024


https://github.com/cjappl created https://github.com/llvm/llvm-project/pull/107167

>From the `ScopedReportingLock` docstring:

```
// Lock sanitizer error reporting and protects against nested errors.
```

Uses a static lock to ensure multiple threads reporting issues at the same time don't have printing collisions. This isn't so important now, but will be with continue mode in the future.

>From 3a9e4defe0e7e315899675d1b2d09a46570dbc08 Mon Sep 17 00:00:00 2001
From: Chris Apple <cja-private at pm.me>
Date: Tue, 3 Sep 2024 16:32:04 -0700
Subject: [PATCH] [compiler-rt][rtsan] Add scoped reporting lock

---
 compiler-rt/lib/rtsan/rtsan_context.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/compiler-rt/lib/rtsan/rtsan_context.cpp b/compiler-rt/lib/rtsan/rtsan_context.cpp
index abeaa1e8483493..97f18dfbbcca8e 100644
--- a/compiler-rt/lib/rtsan/rtsan_context.cpp
+++ b/compiler-rt/lib/rtsan/rtsan_context.cpp
@@ -91,6 +91,8 @@ bool __rtsan::Context::IsBypassed() const { return bypass_depth_ > 0; }
 
 void __rtsan::PrintDiagnostics(const char *intercepted_function_name, uptr pc,
                                uptr bp) {
+  ScopedErrorReportLock l;
+
   fprintf(stderr,
           "Real-time violation: intercepted call to real-time unsafe function "
           "`%s` in real-time context! Stack trace:\n",



More information about the llvm-commits mailing list