diff options
| author | David Major <dmajor@mozilla.com> | 2018-09-26 16:28:39 +0000 |
|---|---|---|
| committer | David Major <dmajor@mozilla.com> | 2018-09-26 16:28:39 +0000 |
| commit | e705624cff2913b66c65023228634ead445e2c20 (patch) | |
| tree | 0ff100e066cda6d496f9035d6ca1a22a8b78f626 | |
| parent | f0a3fd885dfb416423f525e58c901d8632e2780a (diff) | |
| download | bcm5719-llvm-e705624cff2913b66c65023228634ead445e2c20.tar.gz bcm5719-llvm-e705624cff2913b66c65023228634ead445e2c20.zip | |
[winasan] Pin the ASan DLL to prevent unloading
Differential Revision: https://reviews.llvm.org/D52505
llvm-svn: 343123
| -rw-r--r-- | compiler-rt/lib/asan/asan_win.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/asan_win.cc b/compiler-rt/lib/asan/asan_win.cc index 3b6424e2126..c8af8c92068 100644 --- a/compiler-rt/lib/asan/asan_win.cc +++ b/compiler-rt/lib/asan/asan_win.cc @@ -167,6 +167,14 @@ INTERCEPTOR_WINAPI(void, NtTerminateThread, void *rcx) { namespace __asan { void InitializePlatformInterceptors() { + // The interceptors were not designed to be removable, so we have to keep this + // module alive for the life of the process. + HMODULE pinned; + CHECK(GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_PIN, + (LPCWSTR)&InitializePlatformInterceptors, + &pinned)); + ASAN_INTERCEPT_FUNC(CreateThread); ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter); CHECK(::__interception::OverrideFunction("NtTerminateThread", |

