Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion compiler-rt/lib/asan/asan_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
t->GetStartData(params);

auto res = (*params.start_routine)(params.arg);
t->Destroy(); // POSIX calls this from TSD destructor.
return res;
}

Expand All @@ -166,6 +165,13 @@ INTERCEPTOR_WINAPI(HANDLE, CreateThread, LPSECURITY_ATTRIBUTES security,
thr_flags, tid);
}

INTERCEPTOR_WINAPI(void, ExitThread, DWORD dwExitCode) {
AsanThread *t = (AsanThread *)__asan::GetCurrentThread();
if (t)
t->Destroy();
REAL(ExitThread)(dwExitCode);
}

// }}}

namespace __asan {
Expand All @@ -181,6 +187,7 @@ void InitializePlatformInterceptors() {
(LPCWSTR)&InitializePlatformInterceptors, &pinned));

ASAN_INTERCEPT_FUNC(CreateThread);
ASAN_INTERCEPT_FUNC(ExitThread);
ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter);

#ifdef _WIN64
Expand Down