From 76aa2ef0174a2dec9ae50b271bd962a14d1b7f25 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Tue, 19 Feb 2013 11:28:45 +0000 Subject: [PATCH] Fix a bug in mutex_try_to_lock. This was previously trying to unlock a mutex that it didn't own, causing an assertion failure in mutex.cpp. The issue was that the unique_lock went out of scope, releasing the lock on m, then m.unlock() was called on an already-unlocked mutex. This change removes the spurious m.unlock() call. If this test was previously passing for anyone with assertions enabled, then they should investigate bugs in their pthread implementation, as pthread_unlock() should not return 0 if the mutex is currently unlocked. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@175506 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../thread.lock.unique.cons/mutex_try_to_lock.pass.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp index 52815071..b6c64f50 100644 --- a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp +++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp @@ -48,7 +48,6 @@ void f() break; } time_point t1 = Clock::now(); - m.unlock(); ns d = t1 - t0 - ms(250); assert(d < ms(200)); // within 200ms }