summaryrefslogtreecommitdiff
path: root/lib/asan/asan_win.cc
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-08-05 21:47:46 +0000
committerReid Kleckner <rnk@google.com>2016-08-05 21:47:46 +0000
commitc550a8b2d70cabb63dee8be9e324ca59b6e8730b (patch)
treeeb232e2e0a5c4897864ff846275621022a2c6856 /lib/asan/asan_win.cc
parent1e3ef23904fae106d20eedeb9a04aa83f555a0ec (diff)
Fix two tests in Win64 ASan
Go back to intercepting kernel32!RaiseException, and only go for ntdll!RtlRaiseException if that fails. Fixes throw_and_catch.cc test. Work around an issue in LLVM's win64 epilogues. We end up with an epilogue that looks like this, and it drives the Win64 unwinder crazy until stack overflow: call ill_cc!__asan_handle_no_return xor eax,eax add rsp,40h // epilogue starts pop rbp // CSR ud2 // Trap here ret // Ret? nop word ptr [rax+rax] sub rsp,28h // Next function Will file a PR soon. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_win.cc')
-rw-r--r--lib/asan/asan_win.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/asan/asan_win.cc b/lib/asan/asan_win.cc
index 97a913ea9..0616e4087 100644
--- a/lib/asan/asan_win.cc
+++ b/lib/asan/asan_win.cc
@@ -80,6 +80,11 @@ INTERCEPTOR_WINAPI(void, RtlRaiseException, EXCEPTION_RECORD *ExceptionRecord) {
REAL(RtlRaiseException)(ExceptionRecord);
}
+INTERCEPTOR_WINAPI(void, RaiseException, void *a, void *b, void *c, void *d) {
+ CHECK(REAL(RaiseException));
+ __asan_handle_no_return();
+ REAL(RaiseException)(a, b, c, d);
+}
#ifdef _WIN64
@@ -138,10 +143,6 @@ namespace __asan {
void InitializePlatformInterceptors() {
ASAN_INTERCEPT_FUNC(CreateThread);
- // RtlRaiseException is always linked dynamically.
- CHECK(::__interception::OverrideFunction("RtlRaiseException",
- (uptr)WRAP(RtlRaiseException),
- (uptr *)&REAL(RtlRaiseException)));
#ifdef _WIN64
ASAN_INTERCEPT_FUNC(__C_specific_handler);
@@ -149,6 +150,16 @@ void InitializePlatformInterceptors() {
ASAN_INTERCEPT_FUNC(_except_handler3);
ASAN_INTERCEPT_FUNC(_except_handler4);
#endif
+
+ // Try to intercept kernel32!RaiseException, and if that fails, intercept
+ // ntdll!RtlRaiseException instead.
+ if (!::__interception::OverrideFunction("RaiseException",
+ (uptr)WRAP(RaiseException),
+ (uptr *)&REAL(RaiseException))) {
+ CHECK(::__interception::OverrideFunction("RtlRaiseException",
+ (uptr)WRAP(RtlRaiseException),
+ (uptr *)&REAL(RtlRaiseException)));
+ }
}
void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {