Skip to content

Commit 5a3acdc

Browse files
barcharcrazusama54321
authored andcommitted
[asan][windows] Make tests more flexable (llvm#85274)
Contains test changes from llvm#81677 that are simple test changes. For the most part just makes the tests allow more flexibility in the callstacks produced by asan. Note: this PR has the exact changes from llvm#81677 in addition to a revert commit to remove the ones that require other things from that PR. This will be squashed, ofc. I just left things unsquashed for reviewing pleasure :). This is a non-functional-change
1 parent 4781c6a commit 5a3acdc

25 files changed

+143
-241
lines changed

compiler-rt/test/asan/TestCases/Windows/bitfield_uaf.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ void make_access(S *s) {
2121
int main(void) {
2222
S *s = (S*)malloc(sizeof(S));
2323
free(s);
24-
// CHECK: [[ADDR]] is located 0 bytes inside of 4-byte region
25-
// CHECK-LABEL: freed by thread T0 here:
26-
// CHECK: {{#0 .* free }}
27-
// CHECK: {{#1 .* main .*bitfield_uaf.cpp}}:[[@LINE-4]]
28-
// CHECK-LABEL: previously allocated by thread T0 here:
29-
// CHECK: {{#0 .* malloc }}
30-
// CHECK: {{#1 .* main .*bitfield_uaf.cpp}}:[[@LINE-8]]
24+
// CHECK: [[ADDR]] is located 0 bytes inside of 4-byte region
25+
// CHECK-LABEL: freed by thread T0 here:
26+
// CHECK: {{#0 .* free }}
27+
// CHECK: {{ #[1-2] .* main .*bitfield_uaf.cpp}}:[[@LINE-4]]
28+
// CHECK-LABEL: previously allocated by thread T0 here:
29+
// CHECK: {{#0 .* malloc }}
30+
// CHECK: {{ #[1-2] .* main .*bitfield_uaf.cpp}}:[[@LINE-8]]
3131
make_access(s);
3232
return 0;
3333
}

compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
int main() {
77
int *buffer = (int*)calloc(42, sizeof(int));
88
buffer[-1] = 42;
9-
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10-
// CHECK: WRITE of size 4 at [[ADDR]] thread T0
11-
// CHECK-NEXT: {{#0 .* main .*calloc_left_oob.cpp}}:[[@LINE-3]]
12-
// CHECK: [[ADDR]] is located 4 bytes before 168-byte region
13-
// CHECK: allocated by thread T0 here:
14-
// CHECK-NEXT: {{#0 .* calloc }}
15-
// CHECK-NEXT: {{#1 .* main .*calloc_left_oob.cpp}}:[[@LINE-8]]
9+
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10+
// CHECK: WRITE of size 4 at [[ADDR]] thread T0
11+
// CHECK-NEXT: {{#0 .* main .*calloc_left_oob.cpp}}:[[@LINE-3]]
12+
// CHECK: [[ADDR]] is located 4 bytes before 168-byte region
13+
// CHECK: allocated by thread T0 here:
14+
// CHECK: {{#0 .* calloc }}
15+
// CHECK: {{ #[1-2] .* main .*calloc_left_oob.cpp}}:[[@LINE-8]]
1616
free(buffer);
1717
}

compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
int main() {
77
int *buffer = (int*)calloc(42, sizeof(int));
88
buffer[42] = 42;
9-
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10-
// CHECK: WRITE of size 4 at [[ADDR]] thread T0
11-
// CHECK-NEXT: {{#0 .* main .*calloc_right_oob.cpp}}:[[@LINE-3]]
12-
// CHECK: [[ADDR]] is located 0 bytes after 168-byte region
13-
// CHECK: allocated by thread T0 here:
14-
// CHECK-NEXT: {{#0 .* calloc }}
15-
// CHECK-NEXT: {{#1 .* main .*calloc_right_oob.cpp}}:[[@LINE-8]]
9+
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10+
// CHECK: WRITE of size 4 at [[ADDR]] thread T0
11+
// CHECK-NEXT: {{#0 .* main .*calloc_right_oob.cpp}}:[[@LINE-3]]
12+
// CHECK: [[ADDR]] is located 0 bytes after 168-byte region
13+
// CHECK: allocated by thread T0 here:
14+
// CHECK-NEXT: {{#0 .* calloc }}
15+
// CHECK: {{ #[1-2] .* main .*calloc_right_oob.cpp}}:[[@LINE-8]]
1616
free(buffer);
1717
}

compiler-rt/test/asan/TestCases/Windows/calloc_uaf.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ int main() {
77
int *buffer = (int*)calloc(42, sizeof(int));
88
free(buffer);
99
buffer[0] = 42;
10-
// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
11-
// CHECK: WRITE of size 4 at [[ADDR]] thread T0
12-
// CHECK-NEXT: {{#0 .* main .*calloc_uaf.cpp}}:[[@LINE-3]]
13-
// CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
14-
// CHECK: freed by thread T0 here:
15-
// CHECK-NEXT: {{#0 .* free }}
16-
// CHECK-NEXT: {{#1 .* main .*calloc_uaf.cpp}}:[[@LINE-8]]
17-
// CHECK: previously allocated by thread T0 here:
18-
// CHECK-NEXT: {{#0 .* calloc }}
19-
// CHECK-NEXT: {{#1 .* main .*calloc_uaf.cpp}}:[[@LINE-12]]
10+
// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
11+
// CHECK: WRITE of size 4 at [[ADDR]] thread T0
12+
// CHECK-NEXT: {{#0 .* main .*calloc_uaf.cpp}}:[[@LINE-3]]
13+
// CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
14+
// CHECK: freed by thread T0 here:
15+
// CHECK-NEXT: {{#0 .* free }}
16+
// CHECK: {{ #[1-2] .* main .*calloc_uaf.cpp}}:[[@LINE-8]]
17+
// CHECK: previously allocated by thread T0 here:
18+
// CHECK-NEXT: {{#0 .* calloc }}
19+
// CHECK: {{ #[1-2] .* main .*calloc_uaf.cpp}}:[[@LINE-12]]
2020
}

compiler-rt/test/asan/TestCases/Windows/dll_heap_allocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cl %LD %s %Fe%t.dll -DHEAP_LIBRARY %MD \
22
// RUN: %if target={{.*-windows-gnu}} %{ -Wl,--out-implib,%t.lib %}
3-
// RUN: %clang_cl %s %t.lib %Fe%t -fsanitize=address %MT
3+
// RUN: %clang_cl_asan %s %t.lib %Fe%t
44
// RUN: %run %t 2>&1 | FileCheck %s
55

66
// Check that ASan does not fail when releasing allocations that occurred within

compiler-rt/test/asan/TestCases/Windows/dll_host.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,6 @@
55
// Just make sure we can compile this.
66
// The actual compile&run sequence is to be done by the DLL tests.
77
// RUN: %clang_cl_asan -Od %s -Fe%t
8-
//
9-
// Get the list of ASan wrappers exported by the main module RTL:
10-
// note: The mangling decoration (i.e. @4 )is removed because calling convention
11-
// differ from 32-bit and 64-bit.
12-
// RUN: dumpbin /EXPORTS %t | grep -o "__asan_wrap[^ ]*" | sed -e s/@.*// > %t.exports1
13-
//
14-
// The exception handlers differ in 32-bit and 64-bit, so we ignore them:
15-
// RUN: grep '[E]XPORT:' %s | sed -e 's/.*[E]XPORT: //' > %t.exports2
16-
// EXPORT: __asan_wrap__except_handler3
17-
// EXPORT: __asan_wrap__except_handler4
18-
// EXPORT: __asan_wrap___C_specific_handler
19-
//
20-
// Get the list of ASan wrappers imported by the DLL RTL:
21-
// [BEWARE: be really careful with the sed commands, as this test can be run
22-
// from different environments with different shells and seds]
23-
// RUN: grep INTERCEPT_LIBRARY_FUNCTION %p/../../../../lib/asan/asan_win_dll_thunk.cpp \
24-
// RUN: | grep -v define | sed -e s/.*(/__asan_wrap_/ -e s/).*// \
25-
// RUN: > %t.imports1
26-
//
27-
// Add functions interecepted in asan_malloc.win.cpp and asan_win.cpp.
28-
// RUN: grep '[I]MPORT:' %s | sed -e 's/.*[I]MPORT: //' > %t.imports2
29-
// IMPORT: __asan_wrap_HeapAlloc
30-
// IMPORT: __asan_wrap_HeapFree
31-
// IMPORT: __asan_wrap_HeapReAlloc
32-
// IMPORT: __asan_wrap_HeapSize
33-
// IMPORT: __asan_wrap_CreateThread
34-
// IMPORT: __asan_wrap_RaiseException
35-
// IMPORT: __asan_wrap_RtlRaiseException
36-
// IMPORT: __asan_wrap_SetUnhandledExceptionFilter
37-
// IMPORT: __asan_wrap_RtlSizeHeap
38-
// IMPORT: __asan_wrap_RtlAllocateHeap
39-
// IMPORT: __asan_wrap_RtlReAllocateHeap
40-
// IMPORT: __asan_wrap_RtlFreeHeap
41-
//
42-
// RUN: cat %t.imports1 %t.imports2 | sort | uniq > %t.imports-sorted
43-
// RUN: cat %t.exports1 %t.exports2 | sort | uniq > %t.exports-sorted
44-
//
45-
// Now make sure the DLL thunk imports everything:
46-
// RUN: echo
47-
// RUN: echo "=== NOTE === If you see a mismatch below, please update asan_win_dll_thunk.cpp"
48-
// RUN: diff %t.imports-sorted %t.exports-sorted
49-
// REQUIRES: asan-static-runtime
508

519
#include <stdio.h>
5210
#include <windows.h>

compiler-rt/test/asan/TestCases/Windows/dll_malloc_left_oob.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ extern "C" __declspec(dllexport)
77
int test_function() {
88
char *buffer = (char*)malloc(42);
99
buffer[-1] = 42;
10-
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
11-
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
12-
// CHECK-NEXT: test_function {{.*}}dll_malloc_left_oob.cpp:[[@LINE-3]]
13-
// CHECK-NEXT: main {{.*}}dll_host.cpp
14-
//
15-
// CHECK: [[ADDR]] is located 1 bytes before 42-byte region
16-
// CHECK-LABEL: allocated by thread T0 here:
17-
// CHECK-NEXT: malloc
18-
// CHECK-NEXT: test_function {{.*}}dll_malloc_left_oob.cpp:[[@LINE-10]]
19-
// CHECK-NEXT: main {{.*}}dll_host.cpp
20-
// CHECK-LABEL: SUMMARY
10+
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
11+
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
12+
// CHECK-NEXT: test_function {{.*}}dll_malloc_left_oob.cpp:[[@LINE-3]]
13+
// CHECK-NEXT: main {{.*}}dll_host.cpp
14+
//
15+
// CHECK: [[ADDR]] is located 1 bytes before 42-byte region
16+
// CHECK-LABEL: allocated by thread T0 here:
17+
// CHECK-NEXT: malloc
18+
// CHECK: test_function {{.*}}dll_malloc_left_oob.cpp:[[@LINE-10]]
19+
// CHECK-NEXT: main {{.*}}dll_host.cpp
20+
// CHECK-LABEL: SUMMARY
2121
free(buffer);
2222
return 0;
2323
}

compiler-rt/test/asan/TestCases/Windows/dll_malloc_uaf.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ int test_function() {
99
int *buffer = (int*)malloc(42);
1010
free(buffer);
1111
buffer[0] = 42;
12-
// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
13-
// CHECK: WRITE of size 4 at [[ADDR]] thread T0
14-
// CHECK-NEXT: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-3]]
15-
// CHECK-NEXT: main {{.*}}dll_host
16-
//
17-
// CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
18-
// CHECK-LABEL: freed by thread T0 here:
19-
// CHECK-NEXT: free
20-
// CHECK-NEXT: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-10]]
21-
// CHECK-NEXT: main {{.*}}dll_host
22-
//
23-
// CHECK-LABEL: previously allocated by thread T0 here:
24-
// CHECK-NEXT: malloc
25-
// CHECK-NEXT: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-16]]
26-
// CHECK-NEXT: main {{.*}}dll_host
12+
// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
13+
// CHECK: WRITE of size 4 at [[ADDR]] thread T0
14+
// CHECK-NEXT: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-3]]
15+
// CHECK-NEXT: main {{.*}}dll_host
16+
//
17+
// CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
18+
// CHECK-LABEL: freed by thread T0 here:
19+
// CHECK-NEXT: free
20+
// CHECK: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-10]]
21+
// CHECK-NEXT: main {{.*}}dll_host
22+
//
23+
// CHECK-LABEL: previously allocated by thread T0 here:
24+
// CHECK-NEXT: malloc
25+
// CHECK: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-16]]
26+
// CHECK-NEXT: main {{.*}}dll_host
2727
return 0;
2828
}

compiler-rt/test/asan/TestCases/Windows/double_free.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ int main() {
77
int *x = (int*)malloc(42 * sizeof(int));
88
free(x);
99
free(x);
10-
// CHECK: AddressSanitizer: attempting double-free on [[ADDR:0x[0-9a-f]+]]
11-
// CHECK-NEXT: {{#0 .* free }}
12-
// CHECK-NEXT: {{#1 .* main .*double_free.cpp}}:[[@LINE-3]]
13-
// CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
14-
// CHECK-LABEL: freed by thread T0 here:
15-
// CHECK-NEXT: {{#0 .* free }}
16-
// CHECK-NEXT: {{#1 .* main .*double_free.cpp}}:[[@LINE-8]]
17-
// CHECK-LABEL: previously allocated by thread T0 here:
18-
// CHECK-NEXT: {{#0 .* malloc }}
19-
// CHECK-NEXT: {{#1 .* main .*double_free.cpp}}:[[@LINE-12]]
10+
// CHECK: AddressSanitizer: attempting double-free on [[ADDR:0x[0-9a-f]+]]
11+
// CHECK-NEXT: {{#0 .* free }}
12+
// CHECK: {{ #[1-2] .* main .*double_free.cpp}}:[[@LINE-3]]
13+
// CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
14+
// CHECK-LABEL: freed by thread T0 here:
15+
// CHECK-NEXT: {{#0 .* free }}
16+
// CHECK: {{ #[1-2] .* main .*double_free.cpp}}:[[@LINE-8]]
17+
// CHECK-LABEL: previously allocated by thread T0 here:
18+
// CHECK-NEXT: {{#0 .* malloc }}
19+
// CHECK: {{ #[1-2] .* main .*double_free.cpp}}:[[@LINE-12]]
2020
return 0;
2121
}

compiler-rt/test/asan/TestCases/Windows/interface_symbols_windows.cpp

Lines changed: 0 additions & 56 deletions
This file was deleted.

compiler-rt/test/asan/TestCases/Windows/malloc_left_oob.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
int main() {
77
char *buffer = (char*)malloc(42);
88
buffer[-1] = 42;
9-
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10-
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
11-
// CHECK-NEXT: {{#0 .* main .*malloc_left_oob.cpp}}:[[@LINE-3]]
12-
// CHECK: [[ADDR]] is located 1 bytes before 42-byte region
13-
// CHECK: allocated by thread T0 here:
14-
// CHECK-NEXT: {{#0 .* malloc }}
15-
// CHECK-NEXT: {{#1 .* main .*malloc_left_oob.cpp}}:[[@LINE-8]]
9+
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10+
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
11+
// CHECK-NEXT: {{#0 .* main .*malloc_left_oob.cpp}}:[[@LINE-3]]
12+
// CHECK: [[ADDR]] is located 1 bytes before 42-byte region
13+
// CHECK: allocated by thread T0 here:
14+
// CHECK-NEXT: {{#0 .* malloc }}
15+
// CHECK: {{ #[1-2] .* main .*malloc_left_oob.cpp}}:[[@LINE-8]]
1616
free(buffer);
1717
}

compiler-rt/test/asan/TestCases/Windows/malloc_right_oob.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
int main() {
77
char *buffer = (char*)malloc(42);
88
buffer[42] = 42;
9-
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10-
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
11-
// CHECK-NEXT: {{#0 .* main .*malloc_right_oob.cpp}}:[[@LINE-3]]
12-
// CHECK: [[ADDR]] is located 0 bytes after 42-byte region
13-
// CHECK: allocated by thread T0 here:
14-
// CHECK-NEXT: {{#0 .* malloc }}
15-
// CHECK-NEXT: {{#1 .* main .*malloc_right_oob.cpp}}:[[@LINE-8]]
9+
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10+
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
11+
// CHECK-NEXT: {{#0 .* main .*malloc_right_oob.cpp}}:[[@LINE-3]]
12+
// CHECK: [[ADDR]] is located 0 bytes after 42-byte region
13+
// CHECK: allocated by thread T0 here:
14+
// CHECK-NEXT: {{#0 .* malloc }}
15+
// CHECK: {{ #[1-2] .* main .*malloc_right_oob.cpp}}:[[@LINE-8]]
1616
free(buffer);
1717
}

compiler-rt/test/asan/TestCases/Windows/malloc_uaf.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ int main() {
77
char *buffer = (char*)malloc(42);
88
free(buffer);
99
buffer[0] = 42;
10-
// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
11-
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
12-
// CHECK-NEXT: {{#0 .* main .*malloc_uaf.cpp}}:[[@LINE-3]]
13-
// CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
14-
// CHECK: freed by thread T0 here:
15-
// CHECK-NEXT: {{#0 .* free }}
16-
// CHECK-NEXT: {{#1 .* main .*malloc_uaf.cpp}}:[[@LINE-8]]
17-
// CHECK: previously allocated by thread T0 here:
18-
// CHECK-NEXT: {{#0 .* malloc }}
19-
// CHECK-NEXT: {{#1 .* main .*malloc_uaf.cpp}}:[[@LINE-12]]
10+
// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
11+
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
12+
// CHECK-NEXT: {{#0 .* main .*malloc_uaf.cpp}}:[[@LINE-3]]
13+
// CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
14+
// CHECK: freed by thread T0 here:
15+
// CHECK-NEXT: {{#0 .* free }}
16+
// CHECK: {{ #[1-2] .* main .*malloc_uaf.cpp}}:[[@LINE-8]]
17+
// CHECK: previously allocated by thread T0 here:
18+
// CHECK-NEXT: {{#0 .* malloc }}
19+
// CHECK: {{ #[1-2] .* main .*malloc_uaf.cpp}}:[[@LINE-12]]
2020
}

compiler-rt/test/asan/TestCases/Windows/realloc_left_oob.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
int main() {
77
char *buffer = (char*)realloc(0, 42);
88
buffer[-1] = 42;
9-
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10-
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
11-
// CHECK-NEXT: {{#0 .* main .*realloc_left_oob.cpp}}:[[@LINE-3]]
12-
// CHECK: [[ADDR]] is located 1 bytes before 42-byte region
13-
// CHECK: allocated by thread T0 here:
14-
// CHECK-NEXT: {{#0 .* realloc }}
15-
// CHECK-NEXT: {{#1 .* main .*realloc_left_oob.cpp}}:[[@LINE-8]]
9+
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10+
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
11+
// CHECK-NEXT: {{#0 .* main .*realloc_left_oob.cpp}}:[[@LINE-3]]
12+
// CHECK: [[ADDR]] is located 1 bytes before 42-byte region
13+
// CHECK: allocated by thread T0 here:
14+
// CHECK-NEXT: {{#0 .* realloc }}
15+
// CHECK: {{ #[1-2] .* main .*realloc_left_oob.cpp}}:[[@LINE-8]]
1616
free(buffer);
1717
}

compiler-rt/test/asan/TestCases/Windows/realloc_right_oob.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
int main() {
77
char *buffer = (char*)realloc(0, 42);
88
buffer[42] = 42;
9-
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10-
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
11-
// CHECK-NEXT: {{#0 .* main .*realloc_right_oob.cpp}}:[[@LINE-3]]
12-
// CHECK: [[ADDR]] is located 0 bytes after 42-byte region
13-
// CHECK: allocated by thread T0 here:
14-
// CHECK-NEXT: {{#0 .* realloc }}
15-
// CHECK-NEXT: {{#1 .* main .*realloc_right_oob.cpp}}:[[@LINE-8]]
9+
// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10+
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
11+
// CHECK-NEXT: {{#0 .* main .*realloc_right_oob.cpp}}:[[@LINE-3]]
12+
// CHECK: [[ADDR]] is located 0 bytes after 42-byte region
13+
// CHECK: allocated by thread T0 here:
14+
// CHECK-NEXT: {{#0 .* realloc }}
15+
// CHECK: {{ #[1-2] .* main .*realloc_right_oob.cpp}}:[[@LINE-8]]
1616
free(buffer);
1717
}

0 commit comments

Comments
 (0)