[compiler-rt] [ASan][Test-Only] Allow read of size 2 in strcmp.c test (PR #166179)
Dan Blackwell via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 3 07:22:20 PST 2025
https://github.com/DanBlackwell created https://github.com/llvm/llvm-project/pull/166179
Occasionally this test fails on Darwin due to `CHECK: READ of size 1` not matching the actual output `CHECK: READ of size 2`. This can happen when the memory before the string `s1` happens to match the first character of `s2`.
This patch allows for `READ of size 2` to pass in order to account for the above circumstances.
rdar://151317947
>From 08a5a83e608bb25d240478d7ef2823a1bf7561ef Mon Sep 17 00:00:00 2001
From: Dan Blackwell <dan_blackwell at apple.com>
Date: Mon, 3 Nov 2025 15:16:27 +0000
Subject: [PATCH] [ASan][Test-Only] Allow read of size 2 in strcmp.c test
Occasionally this test fails on Darwin due to `CHECK: READ of size 1` not matching the actual output `CHECK: READ of size 2`. This can happen when the memory before the string `s1` happens to match the first character of `s2`.
This patch allows for `READ of size 2` to pass in order to account for the above circumstances.
rdar://151317947
---
compiler-rt/test/asan/TestCases/strcmp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/test/asan/TestCases/strcmp.c b/compiler-rt/test/asan/TestCases/strcmp.c
index 417bd491ebe02..2b31e64768c42 100644
--- a/compiler-rt/test/asan/TestCases/strcmp.c
+++ b/compiler-rt/test/asan/TestCases/strcmp.c
@@ -14,6 +14,8 @@ int main(int argc, char **argv) {
assert(strcmp(s1 - 1, s2));
// CHECK: {{.*ERROR: AddressSanitizer: stack-buffer-underflow on address}}
- // CHECK: READ of size 1
+ // Very rarely `s1[-1]` happens to be '1', resulting in `strcmp` needing to
+ // check 2 bytes before failing, rather than 1 - this should still pass
+ // CHECK: READ of size {{[12]}}
return 0;
}
More information about the llvm-commits
mailing list