From: Dmitry Vyukov Date: Wed, 28 Jul 2021 11:08:49 +0000 (+0200) Subject: sanitizer_common: prohibit Mutex(LINKER_INITIALIZED) X-Git-Tag: upstream/15.0.7~35351 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48cbcb909d9b539680da6b3b8997e3620d085f4e;p=platform%2Fupstream%2Fllvm.git 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 --- 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; };