-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[asan][windows] Make tests more flexable #85274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Enable a bunch of tests that were previously broken in one or the other runtime configuration. Fix tests that were looking for particular frame numbers, these moved around because the new interception methods added a few new frames to the stack. Amy Wishnousky <[email protected]>
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Charlie Barto (barcharcraz) ChangesContains test changes from #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 #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 Patch is 32.49 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/85274.diff 26 Files Affected:
diff --git a/compiler-rt/test/asan/TestCases/Windows/bitfield_uaf.cpp b/compiler-rt/test/asan/TestCases/Windows/bitfield_uaf.cpp
index 8e1a2ae1491486..85310d7ca4e293 100644
--- a/compiler-rt/test/asan/TestCases/Windows/bitfield_uaf.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/bitfield_uaf.cpp
@@ -21,13 +21,13 @@ void make_access(S *s) {
int main(void) {
S *s = (S*)malloc(sizeof(S));
free(s);
-// CHECK: [[ADDR]] is located 0 bytes inside of 4-byte region
-// CHECK-LABEL: freed by thread T0 here:
-// CHECK: {{#0 .* free }}
-// CHECK: {{#1 .* main .*bitfield_uaf.cpp}}:[[@LINE-4]]
-// CHECK-LABEL: previously allocated by thread T0 here:
-// CHECK: {{#0 .* malloc }}
-// CHECK: {{#1 .* main .*bitfield_uaf.cpp}}:[[@LINE-8]]
+ // CHECK: [[ADDR]] is located 0 bytes inside of 4-byte region
+ // CHECK-LABEL: freed by thread T0 here:
+ // CHECK: {{#0 .* free }}
+ // CHECK: {{ .* main .*bitfield_uaf.cpp}}:[[@LINE-4]]
+ // CHECK-LABEL: previously allocated by thread T0 here:
+ // CHECK: {{#0 .* malloc }}
+ // CHECK: {{.* main .*bitfield_uaf.cpp}}:[[@LINE-8]]
make_access(s);
return 0;
}
diff --git a/compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cpp
index b22c359b3dc42f..06c764eab5dd3f 100644
--- a/compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cpp
@@ -6,12 +6,12 @@
int main() {
int *buffer = (int*)calloc(42, sizeof(int));
buffer[-1] = 42;
-// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 4 at [[ADDR]] thread T0
-// CHECK-NEXT: {{#0 .* main .*calloc_left_oob.cpp}}:[[@LINE-3]]
-// CHECK: [[ADDR]] is located 4 bytes before 168-byte region
-// CHECK: allocated by thread T0 here:
-// CHECK-NEXT: {{#0 .* calloc }}
-// CHECK-NEXT: {{#1 .* main .*calloc_left_oob.cpp}}:[[@LINE-8]]
+ // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+ // CHECK: WRITE of size 4 at [[ADDR]] thread T0
+ // CHECK-NEXT: {{#0 .* main .*calloc_left_oob.cpp}}:[[@LINE-3]]
+ // CHECK: [[ADDR]] is located 4 bytes before 168-byte region
+ // CHECK: allocated by thread T0 here:
+ // CHECK: {{#0 .* calloc }}
+ // CHECK: {{.* main .*calloc_left_oob.cpp}}:[[@LINE-8]]
free(buffer);
}
diff --git a/compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cpp
index 9e12f9cf653e09..420c6f2736c613 100644
--- a/compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cpp
@@ -6,12 +6,12 @@
int main() {
int *buffer = (int*)calloc(42, sizeof(int));
buffer[42] = 42;
-// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 4 at [[ADDR]] thread T0
-// CHECK-NEXT: {{#0 .* main .*calloc_right_oob.cpp}}:[[@LINE-3]]
-// CHECK: [[ADDR]] is located 0 bytes after 168-byte region
-// CHECK: allocated by thread T0 here:
-// CHECK-NEXT: {{#0 .* calloc }}
-// CHECK-NEXT: {{#1 .* main .*calloc_right_oob.cpp}}:[[@LINE-8]]
+ // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+ // CHECK: WRITE of size 4 at [[ADDR]] thread T0
+ // CHECK-NEXT: {{#0 .* main .*calloc_right_oob.cpp}}:[[@LINE-3]]
+ // CHECK: [[ADDR]] is located 0 bytes after 168-byte region
+ // CHECK: allocated by thread T0 here:
+ // CHECK-NEXT: {{#0 .* calloc }}
+ // CHECK: {{ .* main .*calloc_right_oob.cpp}}:[[@LINE-8]]
free(buffer);
}
diff --git a/compiler-rt/test/asan/TestCases/Windows/calloc_uaf.cpp b/compiler-rt/test/asan/TestCases/Windows/calloc_uaf.cpp
index 6c225d4c676d08..6830232e2b81fd 100644
--- a/compiler-rt/test/asan/TestCases/Windows/calloc_uaf.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/calloc_uaf.cpp
@@ -7,14 +7,14 @@ int main() {
int *buffer = (int*)calloc(42, sizeof(int));
free(buffer);
buffer[0] = 42;
-// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 4 at [[ADDR]] thread T0
-// CHECK-NEXT: {{#0 .* main .*calloc_uaf.cpp}}:[[@LINE-3]]
-// CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
-// CHECK: freed by thread T0 here:
-// CHECK-NEXT: {{#0 .* free }}
-// CHECK-NEXT: {{#1 .* main .*calloc_uaf.cpp}}:[[@LINE-8]]
-// CHECK: previously allocated by thread T0 here:
-// CHECK-NEXT: {{#0 .* calloc }}
-// CHECK-NEXT: {{#1 .* main .*calloc_uaf.cpp}}:[[@LINE-12]]
+ // CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
+ // CHECK: WRITE of size 4 at [[ADDR]] thread T0
+ // CHECK-NEXT: {{#0 .* main .*calloc_uaf.cpp}}:[[@LINE-3]]
+ // CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
+ // CHECK: freed by thread T0 here:
+ // CHECK-NEXT: {{#0 .* free }}
+ // CHECK: {{.* main .*calloc_uaf.cpp}}:[[@LINE-8]]
+ // CHECK: previously allocated by thread T0 here:
+ // CHECK-NEXT: {{#0 .* calloc }}
+ // CHECK: {{.* main .*calloc_uaf.cpp}}:[[@LINE-12]]
}
diff --git a/compiler-rt/test/asan/TestCases/Windows/defaultlibs_check.cpp b/compiler-rt/test/asan/TestCases/Windows/defaultlibs_check.cpp
new file mode 100644
index 00000000000000..d69f0b2ebb43df
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/Windows/defaultlibs_check.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cl_asan -Od %s -Fe%t /link /WX
+// RUN: %clang_cl_asan -Od %s -Fe%t /link /WX /INFERASANLIBS:DEBUG
+
+// Link with /WX under each configuration to ensure there are
+// no warnings (ex: defaultlib mismatch, pragma detect mismatch)
+// when linking.
+
+int main() { return 0; }
\ No newline at end of file
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_heap_allocation.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_heap_allocation.cpp
index b8c2c1a24d4ce0..3606b1c8163171 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_heap_allocation.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_heap_allocation.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cl %LD %s %Fe%t.dll -DHEAP_LIBRARY %MD \
// RUN: %if target={{.*-windows-gnu}} %{ -Wl,--out-implib,%t.lib %}
-// RUN: %clang_cl %s %t.lib %Fe%t -fsanitize=address %MT
+// RUN: %clang_cl_asan %s %t.lib %Fe%t
// RUN: %run %t 2>&1 | FileCheck %s
// Check that ASan does not fail when releasing allocations that occurred within
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp
index 0757af90d211c3..85b7967e86b510 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp
@@ -5,48 +5,6 @@
// Just make sure we can compile this.
// The actual compile&run sequence is to be done by the DLL tests.
// RUN: %clang_cl_asan -Od %s -Fe%t
-//
-// Get the list of ASan wrappers exported by the main module RTL:
-// note: The mangling decoration (i.e. @4 )is removed because calling convention
-// differ from 32-bit and 64-bit.
-// RUN: dumpbin /EXPORTS %t | grep -o "__asan_wrap[^ ]*" | sed -e s/@.*// > %t.exports1
-//
-// The exception handlers differ in 32-bit and 64-bit, so we ignore them:
-// RUN: grep '[E]XPORT:' %s | sed -e 's/.*[E]XPORT: //' > %t.exports2
-// EXPORT: __asan_wrap__except_handler3
-// EXPORT: __asan_wrap__except_handler4
-// EXPORT: __asan_wrap___C_specific_handler
-//
-// Get the list of ASan wrappers imported by the DLL RTL:
-// [BEWARE: be really careful with the sed commands, as this test can be run
-// from different environments with different shells and seds]
-// RUN: grep INTERCEPT_LIBRARY_FUNCTION %p/../../../../lib/asan/asan_win_dll_thunk.cpp \
-// RUN: | grep -v define | sed -e s/.*(/__asan_wrap_/ -e s/).*// \
-// RUN: > %t.imports1
-//
-// Add functions interecepted in asan_malloc.win.cpp and asan_win.cpp.
-// RUN: grep '[I]MPORT:' %s | sed -e 's/.*[I]MPORT: //' > %t.imports2
-// IMPORT: __asan_wrap_HeapAlloc
-// IMPORT: __asan_wrap_HeapFree
-// IMPORT: __asan_wrap_HeapReAlloc
-// IMPORT: __asan_wrap_HeapSize
-// IMPORT: __asan_wrap_CreateThread
-// IMPORT: __asan_wrap_RaiseException
-// IMPORT: __asan_wrap_RtlRaiseException
-// IMPORT: __asan_wrap_SetUnhandledExceptionFilter
-// IMPORT: __asan_wrap_RtlSizeHeap
-// IMPORT: __asan_wrap_RtlAllocateHeap
-// IMPORT: __asan_wrap_RtlReAllocateHeap
-// IMPORT: __asan_wrap_RtlFreeHeap
-//
-// RUN: cat %t.imports1 %t.imports2 | sort | uniq > %t.imports-sorted
-// RUN: cat %t.exports1 %t.exports2 | sort | uniq > %t.exports-sorted
-//
-// Now make sure the DLL thunk imports everything:
-// RUN: echo
-// RUN: echo "=== NOTE === If you see a mismatch below, please update asan_win_dll_thunk.cpp"
-// RUN: diff %t.imports-sorted %t.exports-sorted
-// REQUIRES: asan-static-runtime
#include <stdio.h>
#include <windows.h>
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_malloc_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_malloc_left_oob.cpp
index 6d550eb966cda3..5ca48fbd683840 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_malloc_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_malloc_left_oob.cpp
@@ -7,17 +7,17 @@ extern "C" __declspec(dllexport)
int test_function() {
char *buffer = (char*)malloc(42);
buffer[-1] = 42;
-// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 1 at [[ADDR]] thread T0
-// CHECK-NEXT: test_function {{.*}}dll_malloc_left_oob.cpp:[[@LINE-3]]
-// CHECK-NEXT: main {{.*}}dll_host.cpp
-//
-// CHECK: [[ADDR]] is located 1 bytes before 42-byte region
-// CHECK-LABEL: allocated by thread T0 here:
-// CHECK-NEXT: malloc
-// CHECK-NEXT: test_function {{.*}}dll_malloc_left_oob.cpp:[[@LINE-10]]
-// CHECK-NEXT: main {{.*}}dll_host.cpp
-// CHECK-LABEL: SUMMARY
+ // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+ // CHECK: WRITE of size 1 at [[ADDR]] thread T0
+ // CHECK-NEXT: test_function {{.*}}dll_malloc_left_oob.cpp:[[@LINE-3]]
+ // CHECK-NEXT: main {{.*}}dll_host.cpp
+ //
+ // CHECK: [[ADDR]] is located 1 bytes before 42-byte region
+ // CHECK-LABEL: allocated by thread T0 here:
+ // CHECK-NEXT: malloc
+ // CHECK: test_function {{.*}}dll_malloc_left_oob.cpp:[[@LINE-10]]
+ // CHECK-NEXT: main {{.*}}dll_host.cpp
+ // CHECK-LABEL: SUMMARY
free(buffer);
return 0;
}
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_malloc_uaf.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_malloc_uaf.cpp
index bc701e92961c99..ae23f86d7ddf49 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_malloc_uaf.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_malloc_uaf.cpp
@@ -9,20 +9,20 @@ int test_function() {
int *buffer = (int*)malloc(42);
free(buffer);
buffer[0] = 42;
-// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 4 at [[ADDR]] thread T0
-// CHECK-NEXT: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-3]]
-// CHECK-NEXT: main {{.*}}dll_host
-//
-// CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
-// CHECK-LABEL: freed by thread T0 here:
-// CHECK-NEXT: free
-// CHECK-NEXT: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-10]]
-// CHECK-NEXT: main {{.*}}dll_host
-//
-// CHECK-LABEL: previously allocated by thread T0 here:
-// CHECK-NEXT: malloc
-// CHECK-NEXT: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-16]]
-// CHECK-NEXT: main {{.*}}dll_host
+ // CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
+ // CHECK: WRITE of size 4 at [[ADDR]] thread T0
+ // CHECK-NEXT: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-3]]
+ // CHECK-NEXT: main {{.*}}dll_host
+ //
+ // CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
+ // CHECK-LABEL: freed by thread T0 here:
+ // CHECK-NEXT: free
+ // CHECK: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-10]]
+ // CHECK-NEXT: main {{.*}}dll_host
+ //
+ // CHECK-LABEL: previously allocated by thread T0 here:
+ // CHECK-NEXT: malloc
+ // CHECK: test_function {{.*}}dll_malloc_uaf.cpp:[[@LINE-16]]
+ // CHECK-NEXT: main {{.*}}dll_host
return 0;
}
diff --git a/compiler-rt/test/asan/TestCases/Windows/double_free.cpp b/compiler-rt/test/asan/TestCases/Windows/double_free.cpp
index 45568e50d0c824..c7299094a1cbf7 100644
--- a/compiler-rt/test/asan/TestCases/Windows/double_free.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/double_free.cpp
@@ -7,15 +7,15 @@ int main() {
int *x = (int*)malloc(42 * sizeof(int));
free(x);
free(x);
-// CHECK: AddressSanitizer: attempting double-free on [[ADDR:0x[0-9a-f]+]]
-// CHECK-NEXT: {{#0 .* free }}
-// CHECK-NEXT: {{#1 .* main .*double_free.cpp}}:[[@LINE-3]]
-// CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
-// CHECK-LABEL: freed by thread T0 here:
-// CHECK-NEXT: {{#0 .* free }}
-// CHECK-NEXT: {{#1 .* main .*double_free.cpp}}:[[@LINE-8]]
-// CHECK-LABEL: previously allocated by thread T0 here:
-// CHECK-NEXT: {{#0 .* malloc }}
-// CHECK-NEXT: {{#1 .* main .*double_free.cpp}}:[[@LINE-12]]
+ // CHECK: AddressSanitizer: attempting double-free on [[ADDR:0x[0-9a-f]+]]
+ // CHECK-NEXT: {{#0 .* free }}
+ // CHECK: {{.* main .*double_free.cpp}}:[[@LINE-3]]
+ // CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
+ // CHECK-LABEL: freed by thread T0 here:
+ // CHECK-NEXT: {{#0 .* free }}
+ // CHECK: {{.* main .*double_free.cpp}}:[[@LINE-8]]
+ // CHECK-LABEL: previously allocated by thread T0 here:
+ // CHECK-NEXT: {{#0 .* malloc }}
+ // CHECK: {{.* main .*double_free.cpp}}:[[@LINE-12]]
return 0;
}
diff --git a/compiler-rt/test/asan/TestCases/Windows/interface_symbols_windows.cpp b/compiler-rt/test/asan/TestCases/Windows/interface_symbols_windows.cpp
deleted file mode 100644
index 1803911a43a9b0..00000000000000
--- a/compiler-rt/test/asan/TestCases/Windows/interface_symbols_windows.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// Check that the interface exported by asan static lib matches the list of
-// functions mentioned in sanitizer_interface.inc.
-//
-// Just make sure we can compile this.
-// RUN: %clang_cl_asan -Od %s -Fe%t
-//
-// note: The mangling decoration (i.e. @4 )is removed because calling convention
-// differ from 32-bit and 64-bit.
-//
-// RUN: dumpbin /EXPORTS %t | sed "s/=.*//" \
-// RUN: | grep -o "\(__asan_\|__ubsan_\|__sanitizer_\|__sancov_\)[^ ]*" \
-// RUN: | grep -v "__asan_wrap" \
-// RUN: | sed -e s/@.*// > %t.exports
-//
-// [BEWARE: be really careful with the sed commands, as this test can be run
-// from different environments with different shells and seds]
-//
-// RUN: sed ':a;N;$!ba;s/([\n ]*/(/g' \
-// RUN: %p/../../../../lib/asan/asan_interface.inc \
-// RUN: %p/../../../../lib/ubsan/ubsan_interface.inc \
-// RUN: %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc \
-// RUN: %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc \
-// RUN: | grep -e "^INTERFACE_FUNCTION" \
-// RUN: | sed -e "s/.*(//" -e "s/).*//" > %t.imports1
-//
-// RUN: sed ':a;N;$!ba;s/([\n ]*/(/g' \
-// RUN: %p/../../../../lib/asan/asan_interface.inc \
-// RUN: %p/../../../../lib/ubsan/ubsan_interface.inc \
-// RUN: %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc \
-// RUN: %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc \
-// RUN: | grep -e "^INTERFACE_WEAK_FUNCTION" \
-// RUN: | sed -e "s/.*(//" -e "s/).*/__dll/" > %t.imports2
-//
-// Add functions not included in the interface lists:
-// RUN: grep '[I]MPORT:' %s | sed -e 's/.*[I]MPORT: //' > %t.imports3
-// IMPORT: __asan_shadow_memory_dynamic_address
-// IMPORT: __asan_get_shadow_memory_dynamic_address
-// IMPORT: __asan_option_detect_stack_use_after_return
-// IMPORT: __asan_should_detect_stack_use_after_return
-// IMPORT: __asan_set_seh_filter
-// IMPORT: __asan_unhandled_exception_filter
-// IMPORT: __asan_test_only_reported_buggy_pointer
-// IMPORT: __ubsan_vptr_type_cache
-//
-// RUN: cat %t.imports1 %t.imports2 %t.imports3 | sort | uniq > %t.imports-sorted
-// RUN: cat %t.exports | sort | uniq > %t.exports-sorted
-//
-// Now make sure the DLL thunk imports everything:
-// RUN: echo
-// RUN: echo "=== NOTE === If you see a mismatch below, please update interface.inc files."
-// RUN: diff %t.imports-sorted %t.exports-sorted
-// REQUIRES: asan-static-runtime
-
-int main() { return 0; }
diff --git a/compiler-rt/test/asan/TestCases/Windows/malloc_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/malloc_left_oob.cpp
index 2ee5fdc7abee2f..fb1ccf5f21b745 100644
--- a/compiler-rt/test/asan/TestCases/Windows/malloc_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/malloc_left_oob.cpp
@@ -6,12 +6,12 @@
int main() {
char *buffer = (char*)malloc(42);
buffer[-1] = 42;
-// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 1 at [[ADDR]] thread T0
-// CHECK-NEXT: {{#0 .* main .*malloc_left_oob.cpp}}:[[@LINE-3]]
-// CHECK: [[ADDR]] is located 1 bytes before 42-byte region
-// CHECK: allocated by thread T0 here:
-// CHECK-NEXT: {{#0 .* malloc }}
-// CHECK-NEXT: {{#1 .* main .*malloc_left_oob.cpp}}:[[@LINE-8]]
+ // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+ // CHECK: WRITE of size 1 at [[ADDR]] thread T0
+ // CHECK-NEXT: {{#0 .* main .*malloc_left_oob.cpp}}:[[@LINE-3]]
+ // CHECK: [[ADDR]] is located 1 bytes before 42-byte region
+ // CHECK: allocated by thread T0 here:
+ // CHECK-NEXT: {{#0 .* malloc }}
+ // CHECK: {{ .* main .*malloc_left_oob.cpp}}:[[@LINE-8]]
free(buffer);
}
diff --git a/compiler-rt/test/asan/TestCases/Windows/malloc_right_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/malloc_right_oob.cpp
index dafca74b4812da..0b9b400cacc4c2 100644
--- a/compiler-rt/test/asan/TestCases/Windows/malloc_right_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/malloc_right_oob.cpp
@@ -6,12 +6,12 @@
int main() {
char *buffer = (char*)malloc(42);
buffer[42] = 42;
-// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 1 at [[ADDR]] thread T0
-// CHECK-NEXT: {{#0 .* main .*malloc_right_oob.cpp}}:[[@LINE-3]]
-// CHECK: [[ADDR]] is located 0 bytes after 42-byte region
-// CHECK: allocated by thread T0 here:
-// CHECK-NEXT: {{#0 .* malloc }}
-// CHECK-NEXT: {{#1 .* main .*malloc_right_oob.cpp}}:[[@LINE-8]]
+ // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+ // CHECK: WRITE of size 1 at [[ADDR]] thread T0
+ // CHECK-NEXT: {{#0 .* main .*malloc_right_oob.cpp}}:[[@LINE-3]]
+ // CHECK: [[ADDR]] is located 0 bytes after 42-byte region
+ // CHECK: allocated by thread T0 here:
+ // CHECK-NEXT: {{#0 .* malloc }}
+ // CHECK: {{ .* main .*malloc_right_oob.cpp}}:[[@LINE-8]]
free(buffer);
}
diff --git a/compiler-rt/test/asan/TestCases/Windows/malloc_uaf.cpp b/compiler-rt/test/asan/TestCases/Windows/malloc_uaf.cpp
index 256582deefe46e..4ffe3b53909c35 100644
--- a/compiler-rt/test/asan/TestCases/Windows/malloc_uaf.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/malloc_uaf.cpp
@@ -7,14 +7,14 @@ int main() {
char *buffer = (char*)malloc(42);
free(buffer);
buffer[0] = 42;
-// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 1 at [[ADDR]] thread T0
-// CHECK-NEXT: {{#0 .* main .*malloc_uaf.cpp}}:[[@LINE-3]]
-// CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
-// CHECK: freed by thread T0 here:
-// CHECK-NEXT: {{#0 .* free }}
-// CHECK-NEXT: {{#1 .* main .*malloc_uaf.cpp}}:[[@LINE-8]]
-// CHECK: previously allocated by thread T0 here:
-// CHECK-NEXT: {{#0 .* malloc }}
-// CHECK-NEXT: {{#1 .* main .*malloc_uaf.cpp}}:[[@LINE-12]]
+ // CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
+ // CHECK: WRITE of size 1 at [[ADDR]] thread T0
+ // CHECK-NEXT: {{#0 .* main .*malloc_uaf.cpp}}:[[@LINE-3]]
+ // CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
+ // CHECK: freed by thread T0 here:
+ // CHECK-NEX...
[truncated]
|
// RUN: | grep -v define | sed -e s/.*(/__asan_wrap_/ -e s/).*// \ | ||
// RUN: > %t.imports1 | ||
// | ||
// Add functions interecepted in asan_malloc.win.cpp and asan_win.cpp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens with this large block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this code verifies that the thunk for the static runtime imports everything the dynamic runtime exports. Since the static runtime is gone there's no reason to check this anymore, it's always true because there's only the dynamic runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, theoretically we could include this after the commit that actually removes the static runtime. But since it's a pure testing change things will "work" even if we remove coverage for this now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if comments addressed
ae380e6
to
d84c1b9
Compare
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
[asan][windows] Make tests more flexable (llvm#85274) (Cherrypick)
Contains test changes from #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 #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