Skip to content

Commit 95b54ae

Browse files
committed
[PR] self - add CAS loop in test so empty BlockFunc doesn't get removed by compiler
1 parent b5dc1aa commit 95b54ae

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

compiler-rt/test/rtsan/stack_suppressions.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
#include <stdlib.h>
1010
#include <unistd.h>
1111

12+
#include <atomic>
1213
#include <vector>
1314

15+
std::atomic<int> cas_atomic{0};
16+
1417
void *MallocViolation() { return malloc(10); }
1518

1619
void VectorViolations() {
@@ -23,7 +26,11 @@ void VectorViolations() {
2326
v.reserve(10);
2427
}
2528

26-
void BlockFunc() [[clang::blocking]] { /* do something blocking */
29+
void BlockFunc() [[clang::blocking]] {
30+
int expected = 0;
31+
while (!cas_atomic.compare_exchange_weak(expected, 1)) {
32+
expected = cas_atomic.load();
33+
}
2734
}
2835

2936
void *process() [[clang::nonblocking]] {

0 commit comments

Comments
 (0)