[libcxx] r291492 - Swap two lines in __mutex_base. On systems with high clock rates, we could mistakenly return no_timeout when a mutex had timed out if we got a tick between these two lines. Thanks to Brian Cain for the bug report.

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 14:32:11 PST 2017


Author: marshall
Date: Mon Jan  9 16:32:11 2017
New Revision: 291492

URL: http://llvm.org/viewvc/llvm-project?rev=291492&view=rev
Log:
Swap two lines in __mutex_base. On systems with high clock rates, we could mistakenly return no_timeout when a mutex had timed out if we got a tick between these two lines.  Thanks to Brian Cain for the bug report.

Modified:
    libcxx/trunk/include/__mutex_base

Modified: libcxx/trunk/include/__mutex_base
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=291492&r1=291491&r2=291492&view=diff
==============================================================================
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Mon Jan  9 16:32:11 2017
@@ -410,8 +410,8 @@ condition_variable::wait_for(unique_lock
     typedef time_point<system_clock, duration<long double, nano> > __sys_tpf;
     typedef time_point<system_clock, nanoseconds> __sys_tpi;
     __sys_tpf _Max = __sys_tpi::max();
-    system_clock::time_point __s_now = system_clock::now();
     steady_clock::time_point __c_now = steady_clock::now();
+    system_clock::time_point __s_now = system_clock::now();
     if (_Max - __d > __s_now)
         __do_timed_wait(__lk, __s_now + __ceil<nanoseconds>(__d));
     else




More information about the cfe-commits mailing list