forked from OSchip/llvm-project
[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 llvm-svn: 277478
This commit is contained in:
parent
4628e37e7f
commit
b0e4a86e05
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue