aboutsummaryrefslogtreecommitdiff
path: root/test/asan/TestCases/Windows
diff options
context:
space:
mode:
Diffstat (limited to 'test/asan/TestCases/Windows')
-rw-r--r--test/asan/TestCases/Windows/bitfield_uaf.cc2
-rw-r--r--test/asan/TestCases/Windows/coverage-basic.cc2
-rw-r--r--test/asan/TestCases/Windows/demangled_names.cc8
-rw-r--r--test/asan/TestCases/Windows/dll_control_c.cc130
-rw-r--r--test/asan/TestCases/Windows/dll_noreturn.cc8
-rw-r--r--test/asan/TestCases/Windows/dll_poison_unpoison.cc6
-rw-r--r--test/asan/TestCases/Windows/dll_report_globals_symbolization_at_startup.cc2
-rw-r--r--test/asan/TestCases/Windows/dll_stack_use_after_return.cc6
-rw-r--r--test/asan/TestCases/Windows/dll_thread_stack_array_left_oob.cc8
-rw-r--r--test/asan/TestCases/Windows/fuse-lld.cc23
-rw-r--r--test/asan/TestCases/Windows/intercept_strdup.cc5
-rw-r--r--test/asan/TestCases/Windows/null_deref.cc2
-rw-r--r--test/asan/TestCases/Windows/operator_delete_wrong_argument.cc2
-rw-r--r--test/asan/TestCases/Windows/operator_new_left_oob.cc2
-rw-r--r--test/asan/TestCases/Windows/operator_new_right_oob.cc2
-rw-r--r--test/asan/TestCases/Windows/operator_new_uaf.cc4
-rw-r--r--test/asan/TestCases/Windows/queue_user_work_item_report.cc2
-rw-r--r--test/asan/TestCases/Windows/report_after_syminitialize.cc6
-rw-r--r--test/asan/TestCases/Windows/report_globals_reload_dll.cc2
-rw-r--r--test/asan/TestCases/Windows/report_globals_vs_freelibrary.cc2
-rw-r--r--test/asan/TestCases/Windows/seh.cc20
-rw-r--r--test/asan/TestCases/Windows/shadow_mapping_failure.cc1
-rw-r--r--test/asan/TestCases/Windows/stack_use_after_return.cc4
-rw-r--r--test/asan/TestCases/Windows/symbols_path.cc2
-rw-r--r--test/asan/TestCases/Windows/thread_stack_array_left_oob.cc2
-rw-r--r--test/asan/TestCases/Windows/thread_stack_array_right_oob.cc2
-rw-r--r--test/asan/TestCases/Windows/unsymbolized.cc25
27 files changed, 231 insertions, 49 deletions
diff --git a/test/asan/TestCases/Windows/bitfield_uaf.cc b/test/asan/TestCases/Windows/bitfield_uaf.cc
index f49d671e3eb3..a1a2657934a4 100644
--- a/test/asan/TestCases/Windows/bitfield_uaf.cc
+++ b/test/asan/TestCases/Windows/bitfield_uaf.cc
@@ -14,7 +14,7 @@ void make_access(S *s) {
s->bf2 = 2;
// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
// CHECK: READ of size {{[124]}} at [[ADDR]]
-// CHECK: {{#0 .* make_access .*bitfield_uaf.cc}}:[[@LINE-3]]
+// CHECK: {{#0 .* make_access.*bitfield_uaf.cc}}:[[@LINE-3]]
// CHECK: {{#1 .* main}}
}
diff --git a/test/asan/TestCases/Windows/coverage-basic.cc b/test/asan/TestCases/Windows/coverage-basic.cc
index 44b499fcb4cd..0ff105d1624e 100644
--- a/test/asan/TestCases/Windows/coverage-basic.cc
+++ b/test/asan/TestCases/Windows/coverage-basic.cc
@@ -1,7 +1,7 @@
// RUN: rm -rf %T/coverage-basic
// RUN: mkdir %T/coverage-basic && cd %T/coverage-basic
// RUN: %clangxx_asan -fsanitize-coverage=func %s -o test.exe
-// RUN: env ASAN_OPTIONS=coverage=1 %run ./test.exe
+// RUN: %env_asan_opts=coverage=1 %run ./test.exe
//
// RUN: %sancov print *.sancov | FileCheck %s
#include <stdio.h>
diff --git a/test/asan/TestCases/Windows/demangled_names.cc b/test/asan/TestCases/Windows/demangled_names.cc
index a528555b1e16..0e5939ee4155 100644
--- a/test/asan/TestCases/Windows/demangled_names.cc
+++ b/test/asan/TestCases/Windows/demangled_names.cc
@@ -43,8 +43,8 @@ int main() {
free(buffer);
A<char*> a(buffer);
// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: foo::bar<42> {{.*}}demangled_names.cc
-// CHECK: foo::spam {{.*}}demangled_names.cc
-// CHECK: baz<char *,1> {{.*}}demangled_names.cc
-// CHECK: A<char *>::~A<char *> {{.*}}demangled_names.cc
+// CHECK: foo::bar<42>{{.*}}demangled_names.cc
+// CHECK: foo::spam{{.*}}demangled_names.cc
+// CHECK: baz<char *,1>{{.*}}demangled_names.cc
+// CHECK: A<char *>::~A<char *>{{.*}}demangled_names.cc
}
diff --git a/test/asan/TestCases/Windows/dll_control_c.cc b/test/asan/TestCases/Windows/dll_control_c.cc
new file mode 100644
index 000000000000..b53cb3f62965
--- /dev/null
+++ b/test/asan/TestCases/Windows/dll_control_c.cc
@@ -0,0 +1,130 @@
+// RUN: %clang_cl_asan -O0 %p/dll_host.cc -Fe%t
+// RUN: %clang_cl_asan -LD -O2 %s -Fe%t.dll
+// RUNX: %run %t %t.dll 2>&1 | FileCheck %s
+
+// Check that ASan does not CHECK fail when SEH is used around a crash from a
+// thread injected by control C.
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+
+static void __declspec(noinline) CrashOnProcessDetach() {
+ printf("CrashOnProcessDetach\n");
+ fflush(stdout);
+ *static_cast<volatile int *>(0) = 0x356;
+}
+
+bool g_is_child = false;
+
+BOOL WINAPI DllMain(PVOID h, DWORD reason, PVOID reserved) {
+ if (reason == DLL_PROCESS_DETACH && g_is_child) {
+ printf("in DllMain DLL_PROCESS_DETACH\n");
+ fflush(stdout);
+ __try {
+ CrashOnProcessDetach();
+ } __except (1) {
+ printf("caught crash\n");
+ fflush(stdout);
+ }
+ }
+ return true;
+}
+
+static void run_child() {
+ // Send this process group Ctrl+C. That should only be this process.
+ printf("GenerateConsoleCtrlEvent\n");
+ fflush(stdout);
+ GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
+ Sleep(10 * 1000); // Wait 10 seconds, and the process should die.
+ printf("unexpected execution after interrupt\n");
+ fflush(stdout);
+ exit(0x42);
+}
+
+static int WINAPI ignore_control_c(DWORD ctrl_type) {
+ // Don't interrupt the parent.
+ return ctrl_type == CTRL_C_EVENT;
+}
+
+static int run_parent() {
+ // Set an environment variable to tell the child process to interrupt itself.
+ if (!SetEnvironmentVariableW(L"DO_CONTROL_C", L"1")) {
+ printf("SetEnvironmentVariableW failed (0x%8lx).\n", GetLastError());
+ fflush(stdout);
+ return 2;
+ }
+
+ // Launch a new process using the current executable with a new console.
+ // Ctrl-C events are console-wide, so we need a new console.
+ STARTUPINFOW si;
+ memset(&si, 0, sizeof(si));
+ si.cb = sizeof(si);
+ // Hides the new console window that we are creating.
+ si.dwFlags |= STARTF_USESHOWWINDOW;
+ si.wShowWindow = SW_HIDE;
+ // Ensures that stdout still goes to the parent despite the new console.
+ si.dwFlags |= STARTF_USESTDHANDLES;
+ si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
+ si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+ si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
+
+ PROCESS_INFORMATION pi;
+ memset(&pi, 0, sizeof(pi));
+ int flags = CREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUP | CREATE_NEW_CONSOLE;
+ if (!CreateProcessW(nullptr, // No module name (use command line)
+ GetCommandLineW(), // Command line
+ nullptr, // Process handle not inheritable
+ nullptr, // Thread handle not inheritable
+ TRUE, // Set handle inheritance to TRUE
+ flags, // Flags to give the child a console
+ nullptr, // Use parent's environment block
+ nullptr, // Use parent's starting directory
+ &si, &pi)) {
+ printf("CreateProcess failed (0x%08lx).\n", GetLastError());
+ fflush(stdout);
+ return 2;
+ }
+
+ // Wait until child process exits.
+ if (WaitForSingleObject(pi.hProcess, INFINITE) == WAIT_FAILED) {
+ printf("WaitForSingleObject failed (0x%08lx).\n", GetLastError());
+ fflush(stdout);
+ return 2;
+ }
+
+ // Get the exit code. It should be the one for ctrl-c events.
+ DWORD rc;
+ if (!GetExitCodeProcess(pi.hProcess, &rc)) {
+ printf("GetExitCodeProcess failed (0x%08lx).\n", GetLastError());
+ fflush(stdout);
+ return 2;
+ }
+ if (rc == STATUS_CONTROL_C_EXIT)
+ printf("child quit with STATUS_CONTROL_C_EXIT\n");
+ else
+ printf("unexpected exit code: 0x%08lx\n", rc);
+ fflush(stdout);
+
+ // Close process and thread handles.
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
+ return 0;
+}
+
+// CHECK: in DllMain DLL_PROCESS_DETACH
+// CHECK: CrashOnProcessDetach
+// CHECK: caught crash
+// CHECK: child quit with STATUS_CONTROL_C_EXIT
+
+extern "C" int __declspec(dllexport) test_function() {
+ wchar_t buf[260];
+ int len = GetEnvironmentVariableW(L"DO_CONTROL_C", buf, 260);
+ if (len > 0) {
+ g_is_child = true;
+ run_child();
+ } else {
+ exit(run_parent());
+ }
+ return 0;
+}
diff --git a/test/asan/TestCases/Windows/dll_noreturn.cc b/test/asan/TestCases/Windows/dll_noreturn.cc
index 79f923eccf84..8b5e3d005875 100644
--- a/test/asan/TestCases/Windows/dll_noreturn.cc
+++ b/test/asan/TestCases/Windows/dll_noreturn.cc
@@ -11,12 +11,12 @@ void noreturn_f() {
_exit(1);
// CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
-// CHECK-NEXT: noreturn_f {{.*}}dll_noreturn.cc:[[@LINE-4]]
-// CHECK-NEXT: test_function {{.*}}dll_noreturn.cc
-// CHECK-NEXT: main {{.*}}dll_host.cc
+// CHECK-NEXT: noreturn_f{{.*}}dll_noreturn.cc:[[@LINE-4]]
+// CHECK-NEXT: test_function{{.*}}dll_noreturn.cc
+// CHECK-NEXT: main{{.*}}dll_host.cc
//
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
-// CHECK-NEXT: noreturn_f {{.*}}dll_noreturn.cc
+// CHECK-NEXT: noreturn_f{{.*}}dll_noreturn.cc
// CHECK: 'buffer' <== Memory access at offset [[OFFSET]] underflows this variable
// CHECK-LABEL: SUMMARY
}
diff --git a/test/asan/TestCases/Windows/dll_poison_unpoison.cc b/test/asan/TestCases/Windows/dll_poison_unpoison.cc
index d486cb122251..9b25a126ef6b 100644
--- a/test/asan/TestCases/Windows/dll_poison_unpoison.cc
+++ b/test/asan/TestCases/Windows/dll_poison_unpoison.cc
@@ -24,12 +24,12 @@ int test_function() {
should_crash(&buffer[96]);
// CHECK: AddressSanitizer: use-after-poison on address [[ADDR:0x[0-9a-f]+]]
// CHECK-NEXT: WRITE of size 1 at [[ADDR]] thread T0
-// CHECK-NEXT: should_crash {{.*}}\dll_poison_unpoison.cc
-// CHECK-NEXT: test_function {{.*}}\dll_poison_unpoison.cc:[[@LINE-4]]
+// CHECK-NEXT: should_crash{{.*}}\dll_poison_unpoison.cc
+// CHECK-NEXT: test_function{{.*}}\dll_poison_unpoison.cc:[[@LINE-4]]
// CHECK-NEXT: main
//
// CHECK: [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
-// CHECK-NEXT: test_function {{.*}}\dll_poison_unpoison.cc
+// CHECK-NEXT: test_function{{.*}}\dll_poison_unpoison.cc
// CHECK: 'buffer' <== Memory access at offset [[OFFSET]] is inside this variable
return 0;
}
diff --git a/test/asan/TestCases/Windows/dll_report_globals_symbolization_at_startup.cc b/test/asan/TestCases/Windows/dll_report_globals_symbolization_at_startup.cc
index fbdb1c145bbe..e07f26f08349 100644
--- a/test/asan/TestCases/Windows/dll_report_globals_symbolization_at_startup.cc
+++ b/test/asan/TestCases/Windows/dll_report_globals_symbolization_at_startup.cc
@@ -1,6 +1,6 @@
// RUN: %clang_cl_asan -LD -O0 -DDLL %s -Fe%t.dll
// RUN: %clang_cl_asan -O0 -DEXE %s %t.lib -Fe%te.exe
-// RUN: env ASAN_OPTIONS=report_globals=2 %run %te.exe 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=report_globals=2 %run %te.exe 2>&1 | FileCheck %s
// FIXME: Currently, the MT runtime build crashes on startup due to dbghelp.dll
// initialization failure.
diff --git a/test/asan/TestCases/Windows/dll_stack_use_after_return.cc b/test/asan/TestCases/Windows/dll_stack_use_after_return.cc
index 6cd74c265b8f..642871846926 100644
--- a/test/asan/TestCases/Windows/dll_stack_use_after_return.cc
+++ b/test/asan/TestCases/Windows/dll_stack_use_after_return.cc
@@ -1,6 +1,6 @@
// RUN: %clang_cl_asan -O0 %p/dll_host.cc -Fe%t
// RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll
-// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=1 not %run %t %t.dll 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=detect_stack_use_after_return=1 not %run %t %t.dll 2>&1 | FileCheck %s
#include <malloc.h>
@@ -17,11 +17,11 @@ int test_function() {
*x = 42;
// CHECK: AddressSanitizer: stack-use-after-return
// CHECK: WRITE of size 1 at [[ADDR:.*]] thread T0
-// CHECK-NEXT: test_function {{.*}}dll_stack_use_after_return.cc:[[@LINE-3]]
+// CHECK-NEXT: test_function{{.*}}dll_stack_use_after_return.cc:[[@LINE-3]]
// CHECK-NEXT: main
//
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
-// CHECK-NEXT: #0 {{.*}} foo {{.*}}dll_stack_use_after_return.cc
+// CHECK-NEXT: #0 {{.*}} foo{{.*}}dll_stack_use_after_return.cc
// CHECK: 'stack_buffer' <== Memory access at offset [[OFFSET]] is inside this variable
return 0;
}
diff --git a/test/asan/TestCases/Windows/dll_thread_stack_array_left_oob.cc b/test/asan/TestCases/Windows/dll_thread_stack_array_left_oob.cc
index 04d3e2ec554b..dc7c7c6ad7e2 100644
--- a/test/asan/TestCases/Windows/dll_thread_stack_array_left_oob.cc
+++ b/test/asan/TestCases/Windows/dll_thread_stack_array_left_oob.cc
@@ -11,10 +11,10 @@ DWORD WINAPI thread_proc(void *context) {
stack_buffer[subscript] = 42;
// CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: WRITE of size 1 at [[ADDR]] thread T1
-// CHECK-NEXT: thread_proc {{.*}}dll_thread_stack_array_left_oob.cc:[[@LINE-3]]
+// CHECK-NEXT: thread_proc{{.*}}dll_thread_stack_array_left_oob.cc:[[@LINE-3]]
//
// CHECK: Address [[ADDR]] is located in stack of thread T1 at offset [[OFFSET:.*]] in frame
-// CHECK-NEXT: thread_proc {{.*}}dll_thread_stack_array_left_oob.cc
+// CHECK-NEXT: thread_proc{{.*}}dll_thread_stack_array_left_oob.cc
//
// CHECK: 'stack_buffer' <== Memory access at offset [[OFFSET]] underflows this variable
@@ -25,8 +25,8 @@ extern "C" __declspec(dllexport)
int test_function() {
HANDLE thr = CreateThread(NULL, 0, thread_proc, NULL, 0, NULL);
// CHECK-LABEL: Thread T1 created by T0 here:
-// CHECK: test_function {{.*}}dll_thread_stack_array_left_oob.cc:[[@LINE-2]]
-// CHECK-NEXT: main {{.*}}dll_host.cc
+// CHECK: test_function{{.*}}dll_thread_stack_array_left_oob.cc:[[@LINE-2]]
+// CHECK-NEXT: main{{.*}}dll_host.cc
// CHECK-LABEL: SUMMARY
if (thr == 0)
return 1;
diff --git a/test/asan/TestCases/Windows/fuse-lld.cc b/test/asan/TestCases/Windows/fuse-lld.cc
new file mode 100644
index 000000000000..76c36d828fb7
--- /dev/null
+++ b/test/asan/TestCases/Windows/fuse-lld.cc
@@ -0,0 +1,23 @@
+// If we have LLD, see that things more or less work.
+//
+// REQUIRES: lld
+//
+// FIXME: Use -fuse-ld=lld after the old COFF linker is removed.
+// FIXME: Test will fail until we add flags for requesting dwarf or cv.
+// RUNX: %clangxx_asan -O2 %s -o %t.exe -fuse-ld=lld -Wl,-debug
+// RUN: %clangxx_asan -c -O2 %s -o %t.o -gdwarf
+// RUN: lld-link %t.o -out:%t.exe -debug -defaultlib:libcmt %asan_lib %asan_cxx_lib
+// RUN: not %run %t.exe 2>&1 | FileCheck %s
+
+#include <stdlib.h>
+
+int main() {
+ char *x = (char*)malloc(10 * sizeof(char));
+ free(x);
+ return x[5];
+ // CHECK: heap-use-after-free
+ // CHECK: free
+ // CHECK: main{{.*}}fuse-lld.cc:[[@LINE-4]]:3
+ // CHECK: malloc
+ // CHECK: main{{.*}}fuse-lld.cc:[[@LINE-7]]:20
+}
diff --git a/test/asan/TestCases/Windows/intercept_strdup.cc b/test/asan/TestCases/Windows/intercept_strdup.cc
index edb1f2f99245..371053480d2c 100644
--- a/test/asan/TestCases/Windows/intercept_strdup.cc
+++ b/test/asan/TestCases/Windows/intercept_strdup.cc
@@ -21,7 +21,8 @@ int main() {
// CHECK: [[ADDR]] is located 1 bytes to the left of 6-byte region
// CHECK: allocated by thread T0 here:
// CHECK: {{#0 .* malloc }}
-// CHECK: {{#1 .*strdup}}
-// CHECK: {{#2 .* main .*}}intercept_strdup.cc:[[@LINE-16]]
+// FIXME: llvm-symbolizer can't find strdup in the CRT.
+// CHECKX: {{#1 .*strdup}}
+// CHECK: {{#2 .* main .*}}intercept_strdup.cc:[[@LINE-17]]
free(ptr);
}
diff --git a/test/asan/TestCases/Windows/null_deref.cc b/test/asan/TestCases/Windows/null_deref.cc
index 202000f59db7..9515602ce89c 100644
--- a/test/asan/TestCases/Windows/null_deref.cc
+++ b/test/asan/TestCases/Windows/null_deref.cc
@@ -10,6 +10,6 @@ static void NullDeref(int *ptr) {
}
int main() {
NullDeref((int*)0);
- // CHECK: {{ #1 0x.* in main.*null_deref.cc:}}[[@LINE-1]]
+ // CHECK: {{ #1 0x.* in main.*null_deref.cc:}}[[@LINE-1]]:3
// CHECK: AddressSanitizer can not provide additional info.
}
diff --git a/test/asan/TestCases/Windows/operator_delete_wrong_argument.cc b/test/asan/TestCases/Windows/operator_delete_wrong_argument.cc
index c3e7daca55b0..46875920c4c1 100644
--- a/test/asan/TestCases/Windows/operator_delete_wrong_argument.cc
+++ b/test/asan/TestCases/Windows/operator_delete_wrong_argument.cc
@@ -7,6 +7,6 @@ int main() {
int *x = new int[42];
delete (x + 1);
// CHECK: AddressSanitizer: attempting free on address which was not malloc()-ed
-// CHECK: {{#0 0x.* operator delete }}
+// CHECK: {{#0 0x.* operator delete}}
// CHECK: {{#1 .* main .*operator_delete_wrong_argument.cc}}:[[@LINE-3]]
}
diff --git a/test/asan/TestCases/Windows/operator_new_left_oob.cc b/test/asan/TestCases/Windows/operator_new_left_oob.cc
index c077f11d68f9..a12db9b1e21e 100644
--- a/test/asan/TestCases/Windows/operator_new_left_oob.cc
+++ b/test/asan/TestCases/Windows/operator_new_left_oob.cc
@@ -11,7 +11,7 @@ int main() {
// CHECK: {{#0 .* main .*operator_new_left_oob.cc}}:[[@LINE-3]]
// CHECK: [[ADDR]] is located 1 bytes to the left of 1-byte region
// CHECK: allocated by thread T0 here:
-// CHECK: {{#0 .* operator new }}
+// CHECK: {{#0 .* operator new}}
// CHECK: {{#1 .* main .*operator_new_left_oob.cc}}:[[@LINE-8]]
delete buffer;
}
diff --git a/test/asan/TestCases/Windows/operator_new_right_oob.cc b/test/asan/TestCases/Windows/operator_new_right_oob.cc
index 7a66d1714b97..7edee5495549 100644
--- a/test/asan/TestCases/Windows/operator_new_right_oob.cc
+++ b/test/asan/TestCases/Windows/operator_new_right_oob.cc
@@ -11,7 +11,7 @@ int main() {
// CHECK: {{#0 .* main .*operator_new_right_oob.cc}}:[[@LINE-3]]
// CHECK: [[ADDR]] is located 0 bytes to the right of 1-byte region
// CHECK: allocated by thread T0 here:
-// CHECK: {{#0 .* operator new }}
+// CHECK: {{#0 .* operator new}}
// CHECK: {{#1 .* main .*operator_new_right_oob.cc}}:[[@LINE-8]]
delete buffer;
}
diff --git a/test/asan/TestCases/Windows/operator_new_uaf.cc b/test/asan/TestCases/Windows/operator_new_uaf.cc
index c435458f0c1c..9d5a4078d073 100644
--- a/test/asan/TestCases/Windows/operator_new_uaf.cc
+++ b/test/asan/TestCases/Windows/operator_new_uaf.cc
@@ -12,10 +12,10 @@ int main() {
// CHECK: {{#0 .* main .*operator_new_uaf.cc}}:[[@LINE-3]]
// CHECK: [[ADDR]] is located 0 bytes inside of 1-byte region
// CHECK-LABEL: freed by thread T0 here:
-// CHECK: {{#0 .* operator delete }}
+// CHECK: {{#0 .* operator delete}}
// CHECK: {{#1 .* main .*operator_new_uaf.cc}}:[[@LINE-8]]
// CHECK-LABEL: previously allocated by thread T0 here:
-// CHECK: {{#0 .* operator new }}
+// CHECK: {{#0 .* operator new}}
// CHECK: {{#1 .* main .*operator_new_uaf.cc}}:[[@LINE-12]]
return 0;
}
diff --git a/test/asan/TestCases/Windows/queue_user_work_item_report.cc b/test/asan/TestCases/Windows/queue_user_work_item_report.cc
index a57e1e767dc7..f0d3d3e7cbcc 100644
--- a/test/asan/TestCases/Windows/queue_user_work_item_report.cc
+++ b/test/asan/TestCases/Windows/queue_user_work_item_report.cc
@@ -11,7 +11,7 @@ DWORD CALLBACK work_item(LPVOID) {
stack_buffer[subscript] = 42;
// CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: WRITE of size 1 at [[ADDR]] thread T1
-// CHECK: {{#0 .* work_item .*queue_user_work_item_report.cc}}:[[@LINE-3]]
+// CHECK: {{#0 .* work_item.*queue_user_work_item_report.cc}}:[[@LINE-3]]
// CHECK: Address [[ADDR]] is located in stack of thread T1 at offset {{.*}} in frame
// CHECK: work_item
SetEvent(done);
diff --git a/test/asan/TestCases/Windows/report_after_syminitialize.cc b/test/asan/TestCases/Windows/report_after_syminitialize.cc
index faf5e35db5f5..d83d7dc264a7 100644
--- a/test/asan/TestCases/Windows/report_after_syminitialize.cc
+++ b/test/asan/TestCases/Windows/report_after_syminitialize.cc
@@ -1,4 +1,5 @@
-// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O0 %s -o %t
+// RUN: %env_asan_opts=external_symbolizer_path=asdf not %run %t 2>&1 | FileCheck %s
#include <windows.h>
#include <dbghelp.h>
@@ -13,7 +14,8 @@ int main() {
*(volatile int*)0 = 42;
// CHECK: ERROR: AddressSanitizer: access-violation on unknown address
+ // CHECK-NEXT: {{WARNING: Failed to use and restart external symbolizer}}
// CHECK-NEXT: {{WARNING: .*DbgHelp}}
- // CHECK: {{#0 0x.* in main.*report_after_syminitialize.cc:}}[[@LINE-3]]
+ // CHECK: {{#0 0x.* in main.*report_after_syminitialize.cc:}}[[@LINE-4]]
// CHECK: AddressSanitizer can not provide additional info.
}
diff --git a/test/asan/TestCases/Windows/report_globals_reload_dll.cc b/test/asan/TestCases/Windows/report_globals_reload_dll.cc
index 8b050975aac1..4adbcc3b5293 100644
--- a/test/asan/TestCases/Windows/report_globals_reload_dll.cc
+++ b/test/asan/TestCases/Windows/report_globals_reload_dll.cc
@@ -1,7 +1,7 @@
// Make sure we can handle reloading the same DLL multiple times.
// RUN: %clang_cl_asan -LD -O0 -DDLL %s -Fe%t.dll
// RUN: %clang_cl_asan -O0 -DEXE %s -Fe%te.exe
-// RUN: env ASAN_OPTIONS=report_globals=1 %run %te.exe %t.dll 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=report_globals=1 %run %te.exe %t.dll 2>&1 | FileCheck %s
#include <windows.h>
#include <stdio.h>
diff --git a/test/asan/TestCases/Windows/report_globals_vs_freelibrary.cc b/test/asan/TestCases/Windows/report_globals_vs_freelibrary.cc
index 72bf36ad0be7..94b97f58f286 100644
--- a/test/asan/TestCases/Windows/report_globals_vs_freelibrary.cc
+++ b/test/asan/TestCases/Windows/report_globals_vs_freelibrary.cc
@@ -1,6 +1,6 @@
// RUN: %clang_cl_asan -LD -O0 -DDLL %s -Fe%t.dll
// RUN: %clang_cl_asan -O0 -DEXE %s -Fe%te.exe
-// RUN: env ASAN_OPTIONS=report_globals=2 %run %te.exe %t.dll 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=report_globals=2 %run %te.exe %t.dll 2>&1 | FileCheck %s
#include <windows.h>
#include <stdio.h>
diff --git a/test/asan/TestCases/Windows/seh.cc b/test/asan/TestCases/Windows/seh.cc
index 50cf6ddba8d6..4cb0c55bc773 100644
--- a/test/asan/TestCases/Windows/seh.cc
+++ b/test/asan/TestCases/Windows/seh.cc
@@ -1,16 +1,17 @@
-// Clang doesn't support SEH on Windows yet, so for the time being we
-// build this program in two parts: the code with SEH is built with CL,
-// the rest is built with Clang. This represents the typical scenario when we
-// build a large project using "clang-cl -fallback -fsanitize=address".
+// Make sure that ASan works with SEH in both Clang and MSVC. MSVC uses a
+// different EH personality depending on the -GS setting, so test both -GS+ and
+// -GS-.
//
-// Check both -GS and -GS- builds:
-// RUN: cl -c %s -Fo%t.obj
+// RUN: cl -c %s -Fo%t.obj -DCOMPILE_SEH
// RUN: %clangxx_asan -o %t.exe %s %t.obj
// RUN: %run %t.exe
//
-// RUN: cl -GS- -c %s -Fo%t.obj
+// RUN: cl -GS- -c %s -Fo%t.obj -DCOMPILE_SEH
// RUN: %clangxx_asan -o %t.exe %s %t.obj
// RUN: %run %t.exe
+//
+// RUN: %clang_cl_asan %s -DCOMPILE_SEH -Fe%t.exe
+// RUN: %run %t.exe
#include <windows.h>
#include <assert.h>
@@ -22,7 +23,7 @@ extern "C" bool __asan_address_is_poisoned(void *p);
void ThrowAndCatch();
-#if !defined(__clang__)
+#if defined(COMPILE_SEH)
__declspec(noinline)
void Throw() {
int local, zero = 0;
@@ -39,8 +40,9 @@ void ThrowAndCatch() {
fprintf(stderr, "__except: %p\n", &local);
}
}
-#else
+#endif
+#if defined(__clang__)
int main() {
char x[32];
fprintf(stderr, "Before: %p poisoned: %d\n", &x,
diff --git a/test/asan/TestCases/Windows/shadow_mapping_failure.cc b/test/asan/TestCases/Windows/shadow_mapping_failure.cc
index 97cd3d60cdfa..9b83947442ed 100644
--- a/test/asan/TestCases/Windows/shadow_mapping_failure.cc
+++ b/test/asan/TestCases/Windows/shadow_mapping_failure.cc
@@ -13,6 +13,5 @@ int main() {
// CHECK: ASan shadow was supposed to be located in the [0x2fff0000-0x{{.*}}ffff] range.
// CHECK: Dumping process modules:
// CHECK-DAG: 0x{{[0-9a-f]*}}-0x{{[0-9a-f]*}} {{.*}}shadow_mapping_failure
-// CHECK-DAG: 0x{{[0-9a-f]*}}-0x{{[0-9a-f]*}} {{.*}}kernel32.dll
// CHECK-DAG: 0x{{[0-9a-f]*}}-0x{{[0-9a-f]*}} {{.*}}ntdll.dll
}
diff --git a/test/asan/TestCases/Windows/stack_use_after_return.cc b/test/asan/TestCases/Windows/stack_use_after_return.cc
index 7955f2685308..9c31922af1de 100644
--- a/test/asan/TestCases/Windows/stack_use_after_return.cc
+++ b/test/asan/TestCases/Windows/stack_use_after_return.cc
@@ -1,5 +1,5 @@
// RUN: %clang_cl_asan -O0 %s -Fe%t
-// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=1 not %run %t 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=detect_stack_use_after_return=1 not %run %t 2>&1 | FileCheck %s
char *x;
@@ -16,7 +16,7 @@ int main() {
// CHECK-NEXT: {{#0 0x.* in main .*stack_use_after_return.cc}}:[[@LINE-3]]
//
// CHECK: is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
-// CHECK-NEXT: {{#0 0x.* in foo .*stack_use_after_return.cc}}
+// CHECK-NEXT: {{#0 0x.* in foo.*stack_use_after_return.cc}}
//
// CHECK: 'stack_buffer' <== Memory access at offset [[OFFSET]] is inside this variable
}
diff --git a/test/asan/TestCases/Windows/symbols_path.cc b/test/asan/TestCases/Windows/symbols_path.cc
index 3c69f8861d78..81ead05c5069 100644
--- a/test/asan/TestCases/Windows/symbols_path.cc
+++ b/test/asan/TestCases/Windows/symbols_path.cc
@@ -16,7 +16,7 @@ int main() {
// CHECK-NEXT: {{#0 .* main .*symbols_path.cc}}:[[@LINE-3]]
// CHECK: [[ADDR]] is located 1 bytes to the left of 42-byte region
// CHECK: allocated by thread T0 here:
-// CHECK-NEXT: {{#0 .* malloc }}
+// CHECK-NEXT: {{#0 .* malloc}}
// CHECK-NEXT: {{#1 .* main .*symbols_path.cc}}:[[@LINE-8]]
free(buffer);
}
diff --git a/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc b/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc
index 63cb8ae1f43c..aac9ecf248d4 100644
--- a/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc
+++ b/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc
@@ -9,7 +9,7 @@ DWORD WINAPI thread_proc(void *) {
stack_buffer[subscript] = 42;
// CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: WRITE of size 1 at [[ADDR]] thread T1
-// CHECK: {{#0 .* thread_proc .*thread_stack_array_left_oob.cc}}:[[@LINE-3]]
+// CHECK: {{#0 .* thread_proc.*thread_stack_array_left_oob.cc}}:[[@LINE-3]]
// CHECK: Address [[ADDR]] is located in stack of thread T1 at offset {{.*}} in frame
// CHECK: thread_proc
return 0;
diff --git a/test/asan/TestCases/Windows/thread_stack_array_right_oob.cc b/test/asan/TestCases/Windows/thread_stack_array_right_oob.cc
index 601a1b8a8760..2982e48dc4f6 100644
--- a/test/asan/TestCases/Windows/thread_stack_array_right_oob.cc
+++ b/test/asan/TestCases/Windows/thread_stack_array_right_oob.cc
@@ -9,7 +9,7 @@ DWORD WINAPI thread_proc(void *) {
stack_buffer[subscript] = 42;
// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: WRITE of size 1 at [[ADDR]] thread T1
-// CHECK: {{#0 .* thread_proc .*thread_stack_array_right_oob.cc}}:[[@LINE-3]]
+// CHECK: {{#0 .* thread_proc.*thread_stack_array_right_oob.cc}}:[[@LINE-3]]
// CHECK: Address [[ADDR]] is located in stack of thread T1 at offset {{.*}} in frame
// CHECK: thread_proc
return 0;
diff --git a/test/asan/TestCases/Windows/unsymbolized.cc b/test/asan/TestCases/Windows/unsymbolized.cc
new file mode 100644
index 000000000000..e44b4bbabb87
--- /dev/null
+++ b/test/asan/TestCases/Windows/unsymbolized.cc
@@ -0,0 +1,25 @@
+// When we link a binary without the -debug flag, ASan should print out VAs
+// instead of RVAs. The frames for main and do_uaf should be above 0x400000,
+// which is the default image base of an executable.
+
+// RUN: rm -f %t.pdb
+// RUN: %clangxx_asan -c -O2 %s -o %t.obj
+// RUN: link /nologo /OUT:%t.exe %t.obj %asan_lib %asan_cxx_lib
+// RUN: not %run %t.exe 2>&1 | FileCheck %s
+
+#include <stdlib.h>
+#include <stdio.h>
+int __attribute__((noinline)) do_uaf(void);
+int main() {
+ int r = do_uaf();
+ printf("r: %d\n", r);
+ return r;
+}
+int do_uaf(void) {
+ char *x = (char*)malloc(10 * sizeof(char));
+ free(x);
+ return x[5];
+ // CHECK: AddressSanitizer: heap-use-after-free
+ // CHECK: #0 {{0x[a-f0-9]+ \(.*[\\/]unsymbolized.cc.*.exe\+0x40[a-f0-9]{4}\)}}
+ // CHECK: #1 {{0x[a-f0-9]+ \(.*[\\/]unsymbolized.cc.*.exe\+0x40[a-f0-9]{4}\)}}
+}