From 6bb2f1d5b542a0fef88c841a12ff46e8a4877ca2 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Fri, 16 Dec 2011 19:13:35 +0000 Subject: [PATCH] Recently the GCD tests started failing because of the invalid size of FakeStack on the worker threads. This patch moves the AsanThread initialization into a separate procedure that's called when AsanThread objects are called for worker threads. Patch by glider@google.com llvm-svn: 146752 --- compiler-rt/lib/asan/asan_mac.cc | 1 + compiler-rt/lib/asan/asan_thread.cc | 6 +++++- compiler-rt/lib/asan/asan_thread.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/asan/asan_mac.cc b/compiler-rt/lib/asan/asan_mac.cc index af4d95e..43e8c00 100644 --- a/compiler-rt/lib/asan/asan_mac.cc +++ b/compiler-rt/lib/asan/asan_mac.cc @@ -106,6 +106,7 @@ void asan_dispatch_call_block_and_release(void *block) { t = (AsanThread*)asan_malloc(sizeof(AsanThread), &stack); new(t) AsanThread(context->parent_tid, /*start_routine*/NULL, /*arg*/NULL, &stack); + t->Init(); asanThreadRegistry().SetCurrent(t); } // Call the original dispatcher for the block. diff --git a/compiler-rt/lib/asan/asan_thread.cc b/compiler-rt/lib/asan/asan_thread.cc index 27fa2fe..a71ad8d 100644 --- a/compiler-rt/lib/asan/asan_thread.cc +++ b/compiler-rt/lib/asan/asan_thread.cc @@ -51,7 +51,7 @@ void AsanThread::ClearShadowForThreadStack() { real_memset((void*)shadow_bot, 0, shadow_top - shadow_bot); } -void *AsanThread::ThreadStart() { +void AsanThread::Init() { SetThreadStackTopAndBottom(); fake_stack_.Init(stack_size()); if (FLAG_v >= 1) { @@ -65,6 +65,10 @@ void *AsanThread::ThreadStart() { CHECK(AddrIsInMem(stack_top_)); ClearShadowForThreadStack(); +} + +void *AsanThread::ThreadStart() { + Init(); if (!start_routine_) { // start_routine_ == NULL if we're on the main thread or on one of the diff --git a/compiler-rt/lib/asan/asan_thread.h b/compiler-rt/lib/asan/asan_thread.h index 2e68b0d..c382c85 100644 --- a/compiler-rt/lib/asan/asan_thread.h +++ b/compiler-rt/lib/asan/asan_thread.h @@ -66,6 +66,7 @@ class AsanThread { void *arg, AsanStackTrace *stack); ~AsanThread(); + void Init(); // Should be called from the thread itself. void *ThreadStart(); uintptr_t stack_top() { return stack_top_; } -- 2.7.4