[compiler-rt] r343123 - [winasan] Pin the ASan DLL to prevent unloading

David Major via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 26 09:28:39 PDT 2018


Author: dmajor
Date: Wed Sep 26 09:28:39 2018
New Revision: 343123

URL: http://llvm.org/viewvc/llvm-project?rev=343123&view=rev
Log:
[winasan] Pin the ASan DLL to prevent unloading

Differential Revision: https://reviews.llvm.org/D52505


Modified:
    compiler-rt/trunk/lib/asan/asan_win.cc

Modified: compiler-rt/trunk/lib/asan/asan_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=343123&r1=343122&r2=343123&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Wed Sep 26 09:28:39 2018
@@ -167,6 +167,14 @@ INTERCEPTOR_WINAPI(void, NtTerminateThre
 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",




More information about the llvm-commits mailing list