[PATCH] D23044: [asan] Remove NtWaitForWorkViaWorkerFactory interceptor

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


This revision was automatically updated to reflect the committed changes.
Closed by commit rL277478: [asan] Remove NtWaitForWorkViaWorkerFactory interceptor (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D23044?vs=66412&id=66490#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23044

Files:
  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

Index: compiler-rt/trunk/lib/asan/asan_win.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc
+++ compiler-rt/trunk/lib/asan/asan_win.cc
@@ -129,37 +129,6 @@
                             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 @@
   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) {
Index: compiler-rt/trunk/test/asan/TestCases/Windows/bind_io_completion_callback.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/bind_io_completion_callback.cc
+++ compiler-rt/trunk/test/asan/TestCases/Windows/bind_io_completion_callback.cc
@@ -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
 
Index: compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc
+++ compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc
@@ -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:
Index: compiler-rt/trunk/test/asan/TestCases/Windows/queue_user_work_item.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/queue_user_work_item.cc
+++ compiler-rt/trunk/test/asan/TestCases/Windows/queue_user_work_item.cc
@@ -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
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23044.66490.patch
Type: text/x-patch
Size: 4288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160802/b627c052/attachment.bin>


More information about the llvm-commits mailing list