[compiler-rt] r343322 - Revert r342652 "[winasan] Unpoison the stack in NtTerminateThread"

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 28 07:41:25 PDT 2018


Author: hans
Date: Fri Sep 28 07:41:25 2018
New Revision: 343322

URL: http://llvm.org/viewvc/llvm-project?rev=343322&view=rev
Log:
Revert r342652 "[winasan] Unpoison the stack in NtTerminateThread"

This seems to cause the thread's exit code to be clobbered, breaking
Chromium tests.

Also revert follow-up r342654.

> In long-running builds we've seen some ASan complaints during thread creation that we suspect are due to leftover poisoning from previous threads whose stacks occupied that memory. This patch adds a hook that unpoisons the stack just before the NtTerminateThread syscall.
>
> Differential Revision: https://reviews.llvm.org/D52091

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=343322&r1=343321&r2=343322&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Fri Sep 28 07:41:25 2018
@@ -154,14 +154,6 @@ INTERCEPTOR_WINAPI(DWORD, CreateThread,
                             asan_thread_start, t, thr_flags, tid);
 }
 
-INTERCEPTOR_WINAPI(void, NtTerminateThread, void *rcx) {
-  // 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(rcx));
-}
-
 // }}}
 
 namespace __asan {
@@ -177,9 +169,7 @@ 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=343322&r1=343321&r2=343322&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc Fri Sep 28 07:41:25 2018
@@ -29,7 +29,6 @@
 // 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