Skip to content

Conversation

@DanBlackwell
Copy link
Contributor

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

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
@llvmbot
Copy link
Member

llvmbot commented Nov 3, 2025

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

Author: Dan Blackwell (DanBlackwell)

Changes

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

Copy link
Contributor

@thurstond thurstond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@DanBlackwell DanBlackwell merged commit 85c7827 into llvm:main Nov 4, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants