[compiler-rt] 48cbcb9 - sanitizer_common: prohibit Mutex(LINKER_INITIALIZED)

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 28 06:09:50 PDT 2021


Author: Dmitry Vyukov
Date: 2021-07-28T15:09:44+02:00
New Revision: 48cbcb909d9b539680da6b3b8997e3620d085f4e

URL: https://github.com/llvm/llvm-project/commit/48cbcb909d9b539680da6b3b8997e3620d085f4e
DIFF: https://github.com/llvm/llvm-project/commit/48cbcb909d9b539680da6b3b8997e3620d085f4e.diff

LOG: sanitizer_common: prohibit Mutex(LINKER_INITIALIZED)

Mutex does not support LINKER_INITIALIZED ctor.
But we used to support it with BlockingMutex.
To prevent potential bugs delete LINKER_INITIALIZED Mutex ctor.
Also mark existing ctor as explicit.

Depends on D106944.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D106945

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_mutex.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_mutex.h b/compiler-rt/lib/sanitizer_common/sanitizer_mutex.h
index cbd1c25eb69f..2d3db282f7c3 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mutex.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mutex.h
@@ -111,7 +111,7 @@ struct MutexMeta {
 
 class CheckedMutex {
  public:
-  constexpr CheckedMutex(MutexType type)
+  explicit constexpr CheckedMutex(MutexType type)
 #if SANITIZER_CHECK_DEADLOCKS
       : type_(type)
 #endif
@@ -154,7 +154,8 @@ class CheckedMutex {
 // but this attribute is not supported by some older compilers.
 class MUTEX Mutex : CheckedMutex {
  public:
-  constexpr Mutex(MutexType type = MutexUnchecked) : CheckedMutex(type) {}
+  explicit constexpr Mutex(MutexType type = MutexUnchecked)
+      : CheckedMutex(type) {}
 
   void Lock() ACQUIRE() {
     CheckedMutex::Lock();
@@ -331,6 +332,7 @@ class MUTEX Mutex : CheckedMutex {
   static constexpr u64 kWriterLock = 1ull << (3 * kCounterWidth);
   static constexpr u64 kWriterSpinWait = 1ull << (3 * kCounterWidth + 1);
 
+  Mutex(LinkerInitialized) = delete;
   Mutex(const Mutex &) = delete;
   void operator=(const Mutex &) = delete;
 };


        


More information about the llvm-commits mailing list