[libcxx] r175506 - 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.

Howard Hinnant hhinnant at apple.com
Tue Feb 19 07:22:27 PST 2013


Thanks!

Howard

On Feb 19, 2013, at 6:28 AM, David Chisnall <csdavec at swan.ac.uk> wrote:

> Author: theraven
> Date: Tue Feb 19 05:28:45 2013
> New Revision: 175506
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=175506&view=rev
> Log:
> 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.
> 
> 
> Modified:
>    libcxx/trunk/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp
> 
> Modified: libcxx/trunk/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp?rev=175506&r1=175505&r2=175506&view=diff
> ==============================================================================
> --- libcxx/trunk/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp (original)
> +++ libcxx/trunk/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp Tue Feb 19 05:28:45 2013
> @@ -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
> }
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list