Skip to content

Commit 7cb9aa4

Browse files
[unittest] Fix a potential hang in CASTest
Fix a wrong use of conditional variable that can cause the test to hang forever in rare conditions due to spurious wake-up calls. rdar://104749939
1 parent 1e998d4 commit 7cb9aa4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/unittests/CAS/LazyAtomicPointerTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ TEST(LazyAtomicPointer, BusyState) {
6060

6161
// Wait for busy state.
6262
std::unique_lock<std::mutex> LBusy(BusyLock);
63-
Busy.wait(LBusy);
63+
Busy.wait(LBusy, [&]() { return IsBusy; });
6464
int *ExistingValue = nullptr;
6565
// Busy state will not exchange the value.
6666
EXPECT_FALSE(Ptr.compare_exchange_weak(ExistingValue, nullptr));

0 commit comments

Comments
 (0)