[compiler-rt] r346560 - Re-land r343606 "[winasan] Unpoison the stack in NtTerminateThread"
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 9 14:07:00 PST 2018
Author: rnk
Date: Fri Nov 9 14:06:59 2018
New Revision: 346560
URL: http://llvm.org/viewvc/llvm-project?rev=346560&view=rev
Log:
Re-land r343606 "[winasan] Unpoison the stack in NtTerminateThread"
This change was reverted because it caused some nacl tests in chromium
to fail. I attempted to reproduce those problems locally, but I was
unable to. Let's reland this and let Chromium's test infrastructure
discover any problems.
Modified:
compiler-rt/trunk/lib/asan/asan_win.cc
compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.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=346560&r1=346559&r2=346560&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Fri Nov 9 14:06:59 2018
@@ -154,6 +154,14 @@ INTERCEPTOR_WINAPI(DWORD, CreateThread,
asan_thread_start, t, thr_flags, tid);
}
+INTERCEPTOR_WINAPI(LONG, NtTerminateThread, HANDLE handle, LONG status) {
+ // Unpoison the terminating thread's stack because the memory may be re-used.
+ NT_TIB *tib = (NT_TIB *)NtCurrentTeb();
+ uptr stackSize = (uptr)tib->StackBase - (uptr)tib->StackLimit;
+ __asan_unpoison_memory_region(tib->StackLimit, stackSize);
+ return REAL(NtTerminateThread(handle, status));
+}
+
// }}}
namespace __asan {
@@ -169,7 +177,9 @@ void InitializePlatformInterceptors() {
ASAN_INTERCEPT_FUNC(CreateThread);
ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter);
-
+ CHECK(::__interception::OverrideFunction("NtTerminateThread",
+ (uptr)WRAP(NtTerminateThread),
+ (uptr *)&REAL(NtTerminateThread)));
#ifdef _WIN64
ASAN_INTERCEPT_FUNC(__C_specific_handler);
#else
Modified: compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc?rev=346560&r1=346559&r2=346560&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc Fri Nov 9 14:06:59 2018
@@ -29,6 +29,7 @@
// IMPORT: __asan_wrap_HeapReAlloc
// IMPORT: __asan_wrap_HeapSize
// IMPORT: __asan_wrap_CreateThread
+// IMPORT: __asan_wrap_NtTerminateThread
// IMPORT: __asan_wrap_RaiseException
// IMPORT: __asan_wrap_RtlRaiseException
// IMPORT: __asan_wrap_SetUnhandledExceptionFilter
More information about the llvm-commits
mailing list