Skip to content

Commit fa77a7a

Browse files
committed
Fix race condition in Mutex LockableThreaded test
If the thread starts slowly enough it will succeed in taking the lock, leading to a deadlock. We saw this test hanging on some of our bots inside of pthread's lock acquire.
1 parent 999aceb commit fa77a7a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

unittests/runtime/Mutex.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ TEST(MutexTest, LockableThreaded) {
153153

154154
mutex.lock();
155155
auto thread = std::thread([&] { ASSERT_FALSE(mutex.try_lock()); });
156-
std::this_thread::sleep_for(std::chrono::milliseconds(10));
157-
mutex.unlock();
158156
thread.join();
157+
mutex.unlock();
159158

160159
thread = std::thread([&] {
161160
ASSERT_TRUE(mutex.try_lock());

0 commit comments

Comments
 (0)