Skip to content

Commit 98174fb

Browse files
authored
[asan] Make frame number checks more flexable (#94307)
Use more flexable regex ([0-9]+) for frame number checks. Since the frame numbers might change if some functions are not inlined. Similar to * 0360f32 * 404bc5c
1 parent 133197a commit 98174fb

11 files changed

+34
-34
lines changed

compiler-rt/test/asan/TestCases/Linux/stack-trace-dlclose.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ int main(int argc, char **argv) {
4141
}
4242
#endif
4343

44-
// CHECK: {{ #0 0x.* in (__interceptor_)?malloc}}
45-
// CHECK: {{ #1 0x.* \(<unknown module>\)}}
46-
// CHECK: {{ #2 0x.* in main}}
44+
// CHECK: {{ #[0-9]+ 0x.* in (__interceptor_)?malloc}}
45+
// CHECK: {{ #[0-9]+ 0x.* \(<unknown module>\)}}
46+
// CHECK: {{ #[0-9]+ 0x.* in main}}

compiler-rt/test/asan/TestCases/Posix/strndup_oob_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ int main(int argc, char **argv) {
1717
char *copy = strndup(kString, 2);
1818
int x = copy[2 + argc]; // BOOM
1919
// CHECK: AddressSanitizer: heap-buffer-overflow
20-
// CHECK: #0 {{.*}}main {{.*}}strndup_oob_test.cpp:[[@LINE-2]]
20+
// CHECK: #{{[0-9]+}} {{.*}}main {{.*}}strndup_oob_test.cpp:[[@LINE-2]]
2121
// CHECK-LABEL: allocated by thread T{{.*}} here:
22-
// CHECK: #{{[01]}} {{.*}}strndup
22+
// CHECK: #{{[0-9]+}} {{.*}}strndup
2323
// CHECK: #{{.*}}main {{.*}}strndup_oob_test.cpp:[[@LINE-6]]
2424
// CHECK-LABEL: SUMMARY
2525
// CHECK: strndup_oob_test.cpp:[[@LINE-7]]

compiler-rt/test/asan/TestCases/calloc-overflow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
int main() {
1111
void *p = calloc(-1, 1000);
1212
// CHECK: {{ERROR: AddressSanitizer: calloc parameters overflow: count \* size \(.* \* 1000\) cannot be represented in type size_t}}
13-
// CHECK: {{#0 0x.* in .*calloc}}
14-
// CHECK: {{#[1-3] 0x.* in main .*calloc-overflow.cpp:}}[[@LINE-3]]
13+
// CHECK: {{#[0-9]+ 0x.* in calloc .*.cpp}}
14+
// CHECK: {{#[0-9]+ 0x.* in main .*calloc-overflow.cpp:}}[[@LINE-3]]
1515
// CHECK: SUMMARY: AddressSanitizer: calloc-overflow
1616

1717
printf("calloc returned: %zu\n", (size_t)p);

compiler-rt/test/asan/TestCases/debug_stacks.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ int main() {
6464
// CHECK: ERROR: AddressSanitizer: heap-use-after-free
6565
// CHECK: WRITE of size 1 at 0x{{.*}}
6666
// CHECK: freed by thread T0 here:
67-
// CHECK: #0 [[FREE_FRAME_0]]
68-
// CHECK: #1 [[FREE_FRAME_1]]
67+
// CHECK: #{{[0-9]+}} [[FREE_FRAME_0]]
68+
// CHECK: #{{[0-9]+}} [[FREE_FRAME_1]]
6969
// CHECK: previously allocated by thread T0 here:
70-
// CHECK: #0 [[ALLOC_FRAME_0]]
71-
// CHECK: #1 [[ALLOC_FRAME_1]]
70+
// CHECK: #{{[0-9+]}} [[ALLOC_FRAME_0]]
71+
// CHECK: #{{[0-9+]}} [[ALLOC_FRAME_1]]
7272

7373
return 0;
7474
}

compiler-rt/test/asan/TestCases/double-free.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ int main(int argc, char **argv) {
1818
free(x);
1919
free(x + argc - 1); // BOOM
2020
// CHECK: AddressSanitizer: attempting double-free{{.*}}in thread T0
21-
// CHECK: #0 0x{{.*}} in {{.*}}free
22-
// CHECK: #{{[1-3]}} 0x{{.*}} in main {{.*}}double-free.cpp:[[@LINE-3]]
21+
// CHECK: #{{[0-9]+}} 0x{{.*}} in {{.*}}free
22+
// CHECK: #{{[0-9]+}} 0x{{.*}} in main {{.*}}double-free.cpp:[[@LINE-3]]
2323
// CHECK: freed by thread T0 here:
2424
// MALLOC-CTX: #0 0x{{.*}} in {{.*}}free
25-
// MALLOC-CTX: #{{[1-3]}} 0x{{.*}} in main {{.*}}double-free.cpp:[[@LINE-7]]
25+
// MALLOC-CTX: #{{[0-9]+}} 0x{{.*}} in main {{.*}}double-free.cpp:[[@LINE-7]]
2626
// CHECK: allocated by thread T0 here:
2727
// MALLOC-CTX: double-free.cpp:[[@LINE-12]]
2828
// CHECK-RECOVER: AddressSanitizer: attempting double-free{{.*}}in thread T0

compiler-rt/test/asan/TestCases/malloc-size-too-big.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ static const size_t kMaxAllowedMallocSizePlusOne =
1717
int main() {
1818
void *p = malloc(kMaxAllowedMallocSizePlusOne);
1919
// CHECK: {{ERROR: AddressSanitizer: requested allocation size .* \(.* after adjustments for alignment, red zones etc\.\) exceeds maximum supported size}}
20-
// CHECK: {{#0 0x.* in .*malloc}}
21-
// CHECK: {{#[1-3] 0x.* in main .*malloc-size-too-big.cpp:}}[[@LINE-3]]
20+
// CHECK: {{#[0-9] 0x.* in .*malloc}}
21+
// CHECK: {{#[0-9] 0x.* in main .*malloc-size-too-big.cpp:}}[[@LINE-3]]
2222
// CHECK: SUMMARY: AddressSanitizer: allocation-size-too-big
2323

2424
printf("malloc returned: %zu\n", (size_t)p);

compiler-rt/test/asan/TestCases/strcpy-overlap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ __attribute__((noinline)) void bad_function() {
3636
char buffer[] = "hello";
3737
// CHECK: strcpy-param-overlap: memory ranges
3838
// CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap
39-
// CHECK: {{#0 0x.* in .*strcpy}}
40-
// CHECK: {{#1 0x.* in bad_function.*strcpy-overlap.cpp:}}[[@LINE+2]]
41-
// CHECK: {{#2 0x.* in main .*strcpy-overlap.cpp:}}[[@LINE+5]]
39+
// CHECK: {{#[0-9]+ 0x.* in .*strcpy .*.cpp}}
40+
// CHECK: {{#[0-9]+ 0x.* in bad_function.*strcpy-overlap.cpp:}}[[@LINE+2]]
41+
// CHECK: {{#[0-9]+ 0x.* in main .*strcpy-overlap.cpp:}}[[@LINE+5]]
4242
strcpy(buffer, buffer + 1); // BOOM
4343
}
4444

compiler-rt/test/asan/TestCases/strdup_oob_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int main(int argc, char **argv) {
2323
// CHECK: AddressSanitizer: heap-buffer-overflow
2424
// CHECK: #0 {{.*}}main {{.*}}strdup_oob_test.cpp:[[@LINE-2]]
2525
// CHECK-LABEL: allocated by thread T{{.*}} here:
26-
// CHECK: #{{[01]}} {{.*}}strdup
26+
// CHECK: #{{[0-9]}}+ {{.*}}strdup
2727
// CHECK: #{{.*}}main {{.*}}strdup_oob_test.cpp:[[@LINE-6]]
2828
// CHECK-LABEL: SUMMARY
2929
// CHECK: strdup_oob_test.cpp:[[@LINE-7]]

compiler-rt/test/asan/TestCases/strncpy-overflow.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ int main(int argc, char **argv) {
2828
char *short_buffer = (char*)malloc(9);
2929
strncpy(short_buffer, hello, 10); // BOOM
3030
// CHECK: {{WRITE of size 10 at 0x.* thread T0}}
31-
// CHECK: {{ #0 0x.* in .*strncpy}}
32-
// CHECK: {{ #1 0x.* in main .*strncpy-overflow.cpp:}}[[@LINE-3]]
31+
// CHECK: {{ #[0-9]+ 0x.* in .*strncpy .*.cpp}}
32+
// CHECK: {{ #[0-9]+ 0x.* in main .*strncpy-overflow.cpp:}}[[@LINE-3]]
3333
// CHECK: {{0x.* is located 0 bytes after 9-byte region}}
3434
// CHECK: {{allocated by thread T0 here:}}
35-
// CHECK: {{ #0 0x.* in .*malloc}}
36-
// CHECK: {{ #[1-3] 0x.* in main .*strncpy-overflow.cpp:}}[[@LINE-8]]
35+
// CHECK: {{ #[0-9]+ 0x.* in .*malloc}}
36+
// CHECK: {{ #[0-9]+ 0x.* in main .*strncpy-overflow.cpp:}}[[@LINE-8]]
3737
return rval + sink_memory(9, short_buffer);
3838
}

compiler-rt/test/asan/TestCases/use-after-free-right.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ int main() {
1515
// CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
1616
// CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
1717
// CHECK: {{WRITE of size 1 at 0x.* thread T0}}
18-
// CHECK: {{ #0 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-4]]
18+
// CHECK: {{ #[0-9]+ 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-4]]
1919
// CHECK: {{0x.* is located 0 bytes inside of 1-byte region .0x.*,0x.*}}
2020
// CHECK: {{freed by thread T0 here:}}
21-
// CHECK: {{ #0 0x.* in .*free}}
22-
// CHECK: {{ #[1-3] 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-9]]
21+
// CHECK: {{ #[0-9]+ 0x.* in .*free .*.cpp}}
22+
// CHECK: {{ #[0-9]+ 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-9]]
2323

2424
// CHECK: {{previously allocated by thread T0 here:}}
25-
// CHECK: {{ #0 0x.* in .*malloc}}
26-
// CHECK: {{ #[1-3] 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-14]]
25+
// CHECK: {{ #[0-9]+ 0x.* in .*malloc}}
26+
// CHECK: {{ #[0-9]+ 0x.* in main .*use-after-free-right.cpp:}}[[@LINE-14]]
2727
}

compiler-rt/test/asan/TestCases/use-after-free.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ int main() {
1212
// CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
1313
// CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
1414
// CHECK: {{READ of size 1 at 0x.* thread T0}}
15-
// CHECK: {{ #0 0x.* in main .*use-after-free.cpp:}}[[@LINE-4]]
15+
// CHECK: {{ #[0-9]+ 0x.* in main .*use-after-free.cpp:}}[[@LINE-4]]
1616
// CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
1717
// CHECK: {{freed by thread T0 here:}}
18-
// CHECK: {{ #0 0x.* in .*free}}
19-
// CHECK: {{ #[1-3] 0x.* in main .*use-after-free.cpp:}}[[@LINE-9]]
18+
// CHECK: {{ #[0-9]+ 0x.* in .*free}}
19+
// CHECK: {{ #[0-9]+ 0x.* in main .*use-after-free.cpp:}}[[@LINE-9]]
2020

2121
// CHECK: {{previously allocated by thread T0 here:}}
22-
// CHECK: {{ #0 0x.* in .*malloc}}
23-
// CHECK: {{ #[1-3] 0x.* in main .*use-after-free.cpp:}}[[@LINE-14]]
22+
// CHECK: {{ #[0-9]+ 0x.* in .*malloc}}
23+
// CHECK: {{ #[0-9]+ 0x.* in main .*use-after-free.cpp:}}[[@LINE-14]]
2424
// CHECK: Shadow byte legend (one shadow byte represents {{[0-9]+}} application bytes):
2525
// CHECK: Global redzone:
2626
// CHECK: ASan internal:

0 commit comments

Comments
 (0)