Bug 1492508: Merge upstream patch to pin the ASan DLL. r=ted

The ASan runtime wasn't designed to be unloaded, so pin it in memory.

Differential Revision: https://phabricator.services.mozilla.com/D6943

--HG--
extra : rebase_source : 843fc91b3150f3b264e321ab89bf723a01fc8b3c
This commit is contained in:
David Major 2018-09-26 17:24:16 -04:00
parent bf2e2a90f0
commit 93da7b7bda
2 changed files with 28 additions and 0 deletions

View File

@ -17,6 +17,7 @@
"workaround-issue38586.patch",
"r342649-hotpatch-8-byte-nops.patch",
"r342652-unpoison-thread-stacks.patch",
"r343123-pin-asan-dll.patch",
"loosen-msvc-detection.patch"
]
}

View File

@ -0,0 +1,27 @@
------------------------------------------------------------------------
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",
------------------------------------------------------------------------