[compiler-rt] 6b67f79 - [lsan] Deflake test on aarch64
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 7 14:44:17 PDT 2024
Author: Vitaly Buka
Date: 2024-09-07T14:44:04-07:00
New Revision: 6b67f79f5f851bfcd5a5861910aedc9e31f377b9
URL: https://github.com/llvm/llvm-project/commit/6b67f79f5f851bfcd5a5861910aedc9e31f377b9
DIFF: https://github.com/llvm/llvm-project/commit/6b67f79f5f851bfcd5a5861910aedc9e31f377b9.diff
LOG: [lsan] Deflake test on aarch64
Looks like registers are clobbered by sched_yield.
Added:
Modified:
compiler-rt/test/lsan/TestCases/use_registers.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/lsan/TestCases/use_registers.cpp b/compiler-rt/test/lsan/TestCases/use_registers.cpp
index a4fbf27aefb6de..9bc7f56859fe43 100644
--- a/compiler-rt/test/lsan/TestCases/use_registers.cpp
+++ b/compiler-rt/test/lsan/TestCases/use_registers.cpp
@@ -11,12 +11,14 @@
#include <stdio.h>
#include <stdlib.h>
-extern "C" void *registers_thread_func(void *arg) {
- int *sync = reinterpret_cast<int *>(arg);
+int sync = 0;
+
+extern "C" void *registers_thread_func(void *) {
void *p = malloc(1337);
print_address("Test alloc: ", 1, p);
fflush(stderr);
+ while(true) {
// To store the pointer, choose a register which is unlikely to be reused by
// a function call.
#if defined(__i386__) || defined(__i686__)
@@ -60,15 +62,13 @@ extern "C" void *registers_thread_func(void *arg) {
#else
#error "Test is not supported on this architecture."
#endif
- __sync_fetch_and_xor(sync, 1);
- while (true)
- sched_yield();
+ __sync_fetch_and_xor(&sync, 1);
+ }
}
int main() {
- int sync = 0;
pthread_t thread_id;
- int res = pthread_create(&thread_id, 0, registers_thread_func, &sync);
+ int res = pthread_create(&thread_id, 0, registers_thread_func, nullptr);
assert(res == 0);
while (!__sync_fetch_and_xor(&sync, 0))
sched_yield();
More information about the llvm-commits
mailing list