[compiler-rt] [scudo] Add two missing locks to enable/disable. (PR #79670)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 10:45:09 PST 2024


================
@@ -136,6 +136,14 @@ class StackDepot {
   u64 operator[](uptr RingPos) const {
     return atomic_load_relaxed(&Ring[RingPos & RingMask]);
   }
+
+  void disable() NO_THREAD_SAFETY_ANALYSIS {
+    RingEndMu.lock();
+  }
+
+  void enable() NO_THREAD_SAFETY_ANALYSIS {
+    RingEndMu.unlock();
+  }
----------------
ChiaHungDuan wrote:

I see. Thanks for the explanation.

For the use case in `release.h`, they are supposed to be acquired after the region mutexes of primary allocator. Which means once you disable the primary allocator, those mutexes won't be held. Given the constraint of thread safety analysis, we don't have an easy way to express that but I can add some runtime debug checks to ensure that assumption.

For the `StackDepot`, even the names `enable/disable` seem to be slightly misleading here but I think it's fine according to the context. Can we add some short comment to the `enable/disable` ?




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


More information about the llvm-commits mailing list