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.
This commit is contained in:
Amanieu d'Antras
2016-05-25 05:44:28 +01:00
parent eea4f0c248
commit d73f5e65ec
4 changed files with 46 additions and 1 deletions

View File

@@ -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)),