diff options
author | Alexander Potapenko <glider@google.com> | 2012-04-05 10:10:57 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2012-04-05 10:10:57 +0000 |
commit | 44016da83fa14a7ea0b47332ac6c0099214b1e26 (patch) | |
tree | 1b8b443891069729e140f6510550ae1ea8a7b43c /compiler-rt | |
parent | 1ea64736883947f76faae5e1e32316186db6b6e2 (diff) | |
download | bcm5719-llvm-44016da83fa14a7ea0b47332ac6c0099214b1e26.tar.gz bcm5719-llvm-44016da83fa14a7ea0b47332ac6c0099214b1e26.zip |
Allow calling GetCurrentTidOrMinusOne() before AsanThreadRegistry was initialized.
llvm-svn: 154091
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/lib/asan/asan_thread_registry.cc | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_thread_registry.h | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/asan_thread_registry.cc b/compiler-rt/lib/asan/asan_thread_registry.cc index 198b2f66246..09f90fa24a6 100644 --- a/compiler-rt/lib/asan/asan_thread_registry.cc +++ b/compiler-rt/lib/asan/asan_thread_registry.cc @@ -37,6 +37,8 @@ void AsanThreadRegistry::Init() { main_thread_summary_.set_thread(&main_thread_); RegisterThread(&main_thread_); SetCurrent(&main_thread_); + // At this point only one thread exists. + inited_ = true; } void AsanThreadRegistry::RegisterThread(AsanThread *thread) { diff --git a/compiler-rt/lib/asan/asan_thread_registry.h b/compiler-rt/lib/asan/asan_thread_registry.h index b011c29386f..491101e748b 100644 --- a/compiler-rt/lib/asan/asan_thread_registry.h +++ b/compiler-rt/lib/asan/asan_thread_registry.h @@ -39,6 +39,7 @@ class AsanThreadRegistry { void SetCurrent(AsanThread *t); int GetCurrentTidOrMinusOne() { + if (!inited_) return 0; AsanThread *t = GetCurrent(); return t ? t->tid() : -1; } @@ -69,6 +70,7 @@ class AsanThreadRegistry { AsanStats accumulated_stats_; int n_threads_; AsanLock mu_; + bool inited_; }; // Returns a single instance of registry. |