Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1119)

Unified Diff: lib/asan/asan_interceptors.cc

Issue 5699064: [ASan] Intercept CreateThread on Windows (Closed)
Patch Set: . Created 13 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/asan/asan_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/asan/asan_interceptors.cc
diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc
index cd824452ff3234b6d1de28839dc01694c6cdad9c..1d85facd75402cf6acc79a9037e5ef0294e2a821 100644
--- a/lib/asan/asan_interceptors.cc
+++ b/lib/asan/asan_interceptors.cc
@@ -254,7 +254,7 @@ void operator delete(void *ptr, std::nothrow_t const&) throw()
void operator delete[](void *ptr, std::nothrow_t const&) throw()
{ OPERATOR_DELETE_BODY;}
-static void *asan_thread_start(void *arg) {
+static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
AsanThread *t = (AsanThread*)arg;
asanThreadRegistry().SetCurrent(t);
return t->ThreadStart();
@@ -579,6 +579,27 @@ INTERCEPTOR(size_t, strnlen, const char *s, size_t maxlen) {
}
#endif
+#if defined(_WIN32)
+INTERCEPTOR_WINAPI(DWORD, CreateThread,
+ void* security, size_t stack_size,
+ DWORD (__stdcall *start_routine)(void*), void* arg,
+ DWORD flags, void* tid) {
+ GET_STACK_TRACE_HERE(kStackTraceMax);
+ int current_tid = asanThreadRegistry().GetCurrentTidOrMinusOne();
+ AsanThread *t = AsanThread::Create(current_tid, start_routine, arg, &stack);
+ asanThreadRegistry().RegisterThread(t);
+ return REAL(CreateThread)(security, stack_size,
+ asan_thread_start, t, flags, tid);
+}
+
+namespace __asan {
+void InitializeWindowsInterceptors() {
+ CHECK(INTERCEPT_FUNCTION(CreateThread));
+}
+
+} // namespace __asan
+#endif
+
// ---------------------- InitializeAsanInterceptors ---------------- {{{1
namespace __asan {
void InitializeAsanInterceptors() {
@@ -654,6 +675,11 @@ void InitializeAsanInterceptors() {
# endif
#endif
+ // Some Windows-specific interceptors.
+#if defined(_WIN32)
+ InitializeWindowsInterceptors();
+#endif
+
// Some Mac-specific interceptors.
#if defined(__APPLE__)
CHECK(INTERCEPT_FUNCTION(dispatch_async_f));
« no previous file with comments | « no previous file | lib/asan/asan_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b