From 5d28bfcfd6086c3328837de9695099ea39048d0d Mon Sep 17 00:00:00 2001 From: Fenrir Date: Sun, 19 Aug 2018 17:48:00 -0600 Subject: Update for nightly-2018-08-18 --- ctr-std/src/sys_common/thread_local.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ctr-std/src/sys_common/thread_local.rs') diff --git a/ctr-std/src/sys_common/thread_local.rs b/ctr-std/src/sys_common/thread_local.rs index d0d6224..bb72cb0 100644 --- a/ctr-std/src/sys_common/thread_local.rs +++ b/ctr-std/src/sys_common/thread_local.rs @@ -161,14 +161,15 @@ impl StaticKey { // Additionally a 0-index of a tls key hasn't been seen on windows, so // we just simplify the whole branch. if imp::requires_synchronized_create() { + // We never call `INIT_LOCK.init()`, so it is UB to attempt to + // acquire this mutex reentrantly! static INIT_LOCK: Mutex = Mutex::new(); - INIT_LOCK.lock(); + let _guard = INIT_LOCK.lock(); let mut key = self.key.load(Ordering::SeqCst); if key == 0 { key = imp::create(self.dtor) as usize; self.key.store(key, Ordering::SeqCst); } - INIT_LOCK.unlock(); rtassert!(key != 0); return key } -- cgit v1.2.3