[compiler-rt] e40ff72 - [TSan][test-only] Make TSan os_unfair_lock.c test check the weak symbol before usage (#161173)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 7 08:15:04 PDT 2025
Author: Dan Blackwell
Date: 2025-10-07T16:15:00+01:00
New Revision: e40ff72df1b0e03b17e2abad40c4b97e7ae447d7
URL: https://github.com/llvm/llvm-project/commit/e40ff72df1b0e03b17e2abad40c4b97e7ae447d7
DIFF: https://github.com/llvm/llvm-project/commit/e40ff72df1b0e03b17e2abad40c4b97e7ae447d7.diff
LOG: [TSan][test-only] Make TSan os_unfair_lock.c test check the weak symbol before usage (#161173)
The os_unfair_lock.c test can currently fail with a null dereference if
compiled on a platform with `os_unfair_lock_lock_with_flags`, but then
executed on a platform without the function.
This patch fixes this by first checking whether the symbol exists, and
falls back to `os_unfair_lock_lock` if not.
rdar://160596542
Added:
Modified:
compiler-rt/test/tsan/Darwin/os_unfair_lock.c
Removed:
################################################################################
diff --git a/compiler-rt/test/tsan/Darwin/os_unfair_lock.c b/compiler-rt/test/tsan/Darwin/os_unfair_lock.c
index e2a491aa98d6d..883154c372c7f 100644
--- a/compiler-rt/test/tsan/Darwin/os_unfair_lock.c
+++ b/compiler-rt/test/tsan/Darwin/os_unfair_lock.c
@@ -22,8 +22,12 @@ void *ThreadWithFlags(void *a) {
defined(__VISIONOS_2_0) || defined(__WATCHOS_11_0)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunguarded-availability-new"
- os_unfair_lock_lock_with_flags(&lock, OS_UNFAIR_LOCK_FLAG_ADAPTIVE_SPIN);
- flags_available = 1;
+ if (os_unfair_lock_lock_with_flags) {
+ os_unfair_lock_lock_with_flags(&lock, OS_UNFAIR_LOCK_FLAG_ADAPTIVE_SPIN);
+ flags_available = 1;
+ } else {
+ os_unfair_lock_lock(&lock);
+ }
# pragma clang diagnostic pop
#else
os_unfair_lock_lock(&lock);
More information about the llvm-commits
mailing list