[compiler-rt] r277478 - [asan] Remove NtWaitForWorkViaWorkerFactory interceptor

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 2 09:17:33 PDT 2016


Author: rnk
Date: Tue Aug  2 11:17:32 2016
New Revision: 277478

URL: http://llvm.org/viewvc/llvm-project?rev=277478&view=rev
Log:
[asan] Remove NtWaitForWorkViaWorkerFactory interceptor

Summary:
On Windows 10, this gets called after TLS has been torn down from NTDLL,
and we crash attempting to return fake_tsd. This interceptor isn't
needed after r242948 anyway, so let's remove it. The ASan runtime can
now tolerate unregistered threads calling __asan_handle_no_return.

Reviewers: vitalybuka, etienneb

Subscribers: kubabrecka, llvm-commits

Differential Revision: https://reviews.llvm.org/D23044

Modified:
    compiler-rt/trunk/lib/asan/asan_win.cc
    compiler-rt/trunk/test/asan/TestCases/Windows/bind_io_completion_callback.cc
    compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc
    compiler-rt/trunk/test/asan/TestCases/Windows/queue_user_work_item.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=277478&r1=277477&r2=277478&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Tue Aug  2 11:17:32 2016
@@ -129,37 +129,6 @@ INTERCEPTOR_WINAPI(DWORD, CreateThread,
                             asan_thread_start, t, thr_flags, tid);
 }
 
-namespace {
-BlockingMutex mu_for_thread_tracking(LINKER_INITIALIZED);
-
-void EnsureWorkerThreadRegistered() {
-  // FIXME: GetCurrentThread relies on TSD, which might not play well with
-  // system thread pools.  We might want to use something like reference
-  // counting to zero out GetCurrentThread() underlying storage when the last
-  // work item finishes?  Or can we disable reclaiming of threads in the pool?
-  BlockingMutexLock l(&mu_for_thread_tracking);
-  if (__asan::GetCurrentThread())
-    return;
-
-  AsanThread *t = AsanThread::Create(
-      /* start_routine */ nullptr, /* arg */ nullptr,
-      /* parent_tid */ -1, /* stack */ nullptr, /* detached */ true);
-  t->Init();
-  asanThreadRegistry().StartThread(t->tid(), 0, 0);
-  SetCurrentThread(t);
-}
-}  // namespace
-
-INTERCEPTOR_WINAPI(DWORD, NtWaitForWorkViaWorkerFactory, DWORD a, DWORD b) {
-  // NtWaitForWorkViaWorkerFactory is called from system worker pool threads to
-  // query work scheduled by BindIoCompletionCallback, QueueUserWorkItem, etc.
-  // System worker pool threads are created at arbitrary point in time and
-  // without using CreateThread, so we wrap NtWaitForWorkViaWorkerFactory
-  // instead and don't register a specific parent_tid/stack.
-  EnsureWorkerThreadRegistered();
-  return REAL(NtWaitForWorkViaWorkerFactory)(a, b);
-}
-
 // }}}
 
 namespace __asan {
@@ -174,12 +143,6 @@ void InitializePlatformInterceptors() {
   ASAN_INTERCEPT_FUNC(_except_handler3);
   ASAN_INTERCEPT_FUNC(_except_handler4);
 #endif
-
-  // NtWaitForWorkViaWorkerFactory is always linked dynamically.
-  CHECK(::__interception::OverrideFunction(
-      "NtWaitForWorkViaWorkerFactory",
-      (uptr)WRAP(NtWaitForWorkViaWorkerFactory),
-      (uptr *)&REAL(NtWaitForWorkViaWorkerFactory)));
 }
 
 void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {

Modified: compiler-rt/trunk/test/asan/TestCases/Windows/bind_io_completion_callback.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/bind_io_completion_callback.cc?rev=277478&r1=277477&r2=277478&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/bind_io_completion_callback.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/bind_io_completion_callback.cc Tue Aug  2 11:17:32 2016
@@ -1,11 +1,6 @@
 // Make sure we can throw exceptions from work items executed via
 // BindIoCompletionCallback.
 //
-// Clang doesn't support exceptions on Windows yet, so for the time being we
-// build this program in two parts: the code with exceptions is built with CL,
-// the rest is built with Clang.  This represents the typical scenario when we
-// build a large project using "clang-cl -fallback -fsanitize=address".
-//
 // RUN: %clangxx_asan %s -o %t.exe
 // RUN: %run %t.exe 2>&1 | FileCheck %s
 

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=277478&r1=277477&r2=277478&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc Tue Aug  2 11:17:32 2016
@@ -24,7 +24,6 @@
 // IMPORT: __asan_wrap_HeapReAlloc
 // IMPORT: __asan_wrap_HeapSize
 // IMPORT: __asan_wrap_CreateThread
-// IMPORT: __asan_wrap_NtWaitForWorkViaWorkerFactory
 // IMPORT: __asan_wrap_RaiseException
 //
 // The exception handlers differ in 32-bit and 64-bit, so we ignore them:

Modified: compiler-rt/trunk/test/asan/TestCases/Windows/queue_user_work_item.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/queue_user_work_item.cc?rev=277478&r1=277477&r2=277478&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/queue_user_work_item.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/queue_user_work_item.cc Tue Aug  2 11:17:32 2016
@@ -1,11 +1,6 @@
 // Make sure we can throw exceptions from work items executed via
 // QueueUserWorkItem.
 //
-// Clang doesn't support exceptions on Windows yet, so for the time being we
-// build this program in two parts: the code with exceptions is built with CL,
-// the rest is built with Clang.  This represents the typical scenario when we
-// build a large project using "clang-cl -fallback -fsanitize=address".
-//
 // RUN: %clangxx_asan %s -o %t.exe
 // RUN: %run %t.exe 2>&1 | FileCheck %s
 




More information about the llvm-commits mailing list