diff --git a/library/std/src/sys_common/condvar/check.rs b/library/std/src/sys_common/condvar/check.rs index 7671850ac55b8..d0d0d59651895 100644 --- a/library/std/src/sys_common/condvar/check.rs +++ b/library/std/src/sys_common/condvar/check.rs @@ -24,8 +24,14 @@ impl SameMutexCheck { } pub fn verify(&self, mutex: &MovableMutex) { let addr = mutex.raw() as *const imp::Mutex as *const () as *mut _; - match self.addr.compare_exchange(ptr::null_mut(), addr, Ordering::SeqCst, Ordering::SeqCst) - { + // Relaxed is okay here because we never read through `self.addr`, and only use it to + // compare addresses. + match self.addr.compare_exchange( + ptr::null_mut(), + addr, + Ordering::Relaxed, + Ordering::Relaxed, + ) { Ok(_) => {} // Stored the address Err(n) if n == addr => {} // Lost a race to store the same address _ => panic!("attempted to use a condition variable with two mutexes"),