gecko-dev/build/build-clang/r343123-pin-asan-dll.patch
David Major 93da7b7bda 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
2018-09-26 17:24:16 -04:00

28 lines
1.1 KiB
Diff

------------------------------------------------------------------------
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",
------------------------------------------------------------------------