From 08a5a83e608bb25d240478d7ef2823a1bf7561ef Mon Sep 17 00:00:00 2001 From: Dan Blackwell 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; }