[PATCH] D23044: [asan] Remove NtWaitForWorkViaWorkerFactory interceptor
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 1 18:11:39 PDT 2016
rnk created this revision.
rnk added reviewers: vitalybuka, etienneb.
rnk added a subscriber: llvm-commits.
Herald added a subscriber: kubabrecka.
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.
https://reviews.llvm.org/D23044
Files:
lib/asan/asan_win.cc
test/asan/TestCases/Windows/bind_io_completion_callback.cc
test/asan/TestCases/Windows/dll_host.cc
test/asan/TestCases/Windows/queue_user_work_item.cc
Index: test/asan/TestCases/Windows/queue_user_work_item.cc
===================================================================
--- test/asan/TestCases/Windows/queue_user_work_item.cc
+++ 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
Index: test/asan/TestCases/Windows/dll_host.cc
===================================================================
--- test/asan/TestCases/Windows/dll_host.cc
+++ 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: test/asan/TestCases/Windows/bind_io_completion_callback.cc
===================================================================
--- test/asan/TestCases/Windows/bind_io_completion_callback.cc
+++ 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: lib/asan/asan_win.cc
===================================================================
--- lib/asan/asan_win.cc
+++ 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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23044.66412.patch
Type: text/x-patch
Size: 4072 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160802/06e7bd44/attachment.bin>
More information about the llvm-commits
mailing list