From 69c4c6f192271918d1bf64a84d3f8a41d1e943ac Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Tue, 28 Feb 2012 15:56:07 +0000 Subject: Fix a potential race in guard logic. --- src/guard.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/guard.cc b/src/guard.cc index f236053..1cbeb58 100644 --- a/src/guard.cc +++ b/src/guard.cc @@ -103,6 +103,10 @@ extern "C" int __cxa_guard_acquire(volatile int64_t *guard_object) // the lock at the same time. while (!__sync_bool_compare_and_swap_4(lock, 0, 1)) { + if (1 == ((*guard_object) >> 56)) + { + break; + } sched_yield(); } // We have to test the guard again, in case another thread has performed -- cgit v1.2.3