diff options
author | Kostya Serebryany <kcc@google.com> | 2018-08-30 23:22:26 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2018-08-30 23:22:26 +0000 |
commit | bdd3a3bdaf966d452458455c9cda7c89cbb41e3a (patch) | |
tree | 7a44e2237b43bb24fd78b977b6083cd78558fab0 /lib/hwasan | |
parent | a370a199870212b25cb77c01da3cbd8d0f895456 (diff) | |
download | compiler-rt-bdd3a3bdaf966d452458455c9cda7c89cbb41e3a.tar.gz |
[hwasan] fix the linux-only pthread_create interceptor and reinstate the two threaded tests
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@341143 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/hwasan')
-rw-r--r-- | lib/hwasan/hwasan_interceptors.cc | 15 | ||||
-rw-r--r-- | lib/hwasan/hwasan_thread.h | 11 |
2 files changed, 14 insertions, 12 deletions
diff --git a/lib/hwasan/hwasan_interceptors.cc b/lib/hwasan/hwasan_interceptors.cc index 3c892c5c6..8512c049c 100644 --- a/lib/hwasan/hwasan_interceptors.cc +++ b/lib/hwasan/hwasan_interceptors.cc @@ -292,14 +292,6 @@ INTERCEPTOR(void *, malloc, SIZE_T size) { extern "C" int pthread_attr_init(void *attr); extern "C" int pthread_attr_destroy(void *attr); -struct ThreadStartArg { - thread_callback_t callback; - void *param; - // TODO: something crazy is going on with pthread_create overwriting parts - // of the stack, hense the padding. - char padding[1000]; -}; - static void *HwasanThreadStartFunc(void *arg) { __hwasan_thread_enter(); ThreadStartArg *A = reinterpret_cast<ThreadStartArg*>(arg); @@ -309,11 +301,10 @@ static void *HwasanThreadStartFunc(void *arg) { INTERCEPTOR(int, pthread_create, void *th, void *attr, void *(*callback)(void*), void * param) { ScopedTaggingDisabler disabler; - ThreadStartArg A; - A.callback = callback; - A.param = param; + ThreadStartArg *A = GetCurrentThread()->thread_start_arg(); + *A = {callback, param}; int res = REAL(pthread_create)(UntagPtr(th), UntagPtr(attr), - &HwasanThreadStartFunc, &A); + &HwasanThreadStartFunc, A); return res; } #endif // HWASAN_WITH_INTERCEPTORS diff --git a/lib/hwasan/hwasan_thread.h b/lib/hwasan/hwasan_thread.h index 16df85e6a..11ecf2f10 100644 --- a/lib/hwasan/hwasan_thread.h +++ b/lib/hwasan/hwasan_thread.h @@ -19,6 +19,11 @@ namespace __hwasan { +struct ThreadStartArg { + thread_callback_t callback; + void *param; +}; + class Thread { public: static Thread *Create(thread_callback_t start_routine, void *arg); @@ -70,6 +75,10 @@ class Thread { } } + // Return a scratch ThreadStartArg object to be used in + // pthread_create interceptor. + ThreadStartArg *thread_start_arg() { return &thread_start_arg_; } + private: // NOTE: There is no Thread constructor. It is allocated // via mmap() and *must* be valid in zero-initialized state. @@ -99,6 +108,8 @@ class Thread { static Thread *main_thread; u32 tagging_disabled_; // if non-zero, malloc uses zero tag in this thread. + + ThreadStartArg thread_start_arg_; }; Thread *GetCurrentThread(); |