Skip to content

Commit 85c7827

Browse files
authored
[ASan][Test-Only] Allow read of size 2 in strcmp.c test (#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
1 parent c4ac31d commit 85c7827

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler-rt/test/asan/TestCases/strcmp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ int main(int argc, char **argv) {
1414
assert(strcmp(s1 - 1, s2));
1515

1616
// CHECK: {{.*ERROR: AddressSanitizer: stack-buffer-underflow on address}}
17-
// CHECK: READ of size 1
17+
// Very rarely `s1[-1]` happens to be '1', resulting in `strcmp` needing to
18+
// check 2 bytes before failing, rather than 1 - this should still pass
19+
// CHECK: READ of size {{[12]}}
1820
return 0;
1921
}

0 commit comments

Comments
 (0)