------------------------------------------------------------------------ r343123 | dmajor | 2018-09-26 12:28:39 -0400 (Wed, 26 Sep 2018) | 5 lines [winasan] Pin the ASan DLL to prevent unloading Differential Revision: https://reviews.llvm.org/D52505 =================================================================== --- a/compiler-rt/lib/asan/asan_win.cc (revision 343122) +++ b/compiler-rt/lib/asan/asan_win.cc (revision 343123) @@ -167,6 +167,14 @@ 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", ------------------------------------------------------------------------