From d73f5e65ecbcb6a0acb908b54226edfccf47eccc Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Wed, 25 May 2016 05:44:28 +0100 Subject: Fix undefined behavior when re-locking a mutex from the same thread The only applies to pthread mutexes. We solve this by creating the mutex with the PTHREAD_MUTEX_NORMAL type, which guarantees that re-locking from the same thread will deadlock. --- src/libstd/sys/windows/mutex.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/libstd/sys/windows') diff --git a/src/libstd/sys/windows/mutex.rs b/src/libstd/sys/windows/mutex.rs index b770156582d..8762b34e3da 100644 --- a/src/libstd/sys/windows/mutex.rs +++ b/src/libstd/sys/windows/mutex.rs @@ -64,6 +64,8 @@ impl Mutex { held: UnsafeCell::new(false), } } + #[inline] + pub unsafe fn init(&mut self) {} pub unsafe fn lock(&self) { match kind() { Kind::SRWLock => c::AcquireSRWLockExclusive(raw(self)), -- cgit 1.4.1-3-g733a5