[compiler-rt] [ASan][Test-Only] Allow read of size 2 in strcmp.c test (PR #166179)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 07:22:54 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Dan Blackwell (DanBlackwell)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/166179.diff


1 Files Affected:

- (modified) compiler-rt/test/asan/TestCases/strcmp.c (+3-1) 


``````````diff
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;
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/166179


More information about the llvm-commits mailing list