diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-09-12 08:16:28 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-09-12 08:16:28 +0000 |
commit | 96a575f05b2a45774170a118ea69ddae3659b645 (patch) | |
tree | da8f9ebfa459dad98e83f0b03f0d744e1b24452a /lib/asan/asan_thread.h | |
parent | 86b88b80bdb7ea9a265f8946e7918bcc388abceb (diff) | |
download | compiler-rt-96a575f05b2a45774170a118ea69ddae3659b645.tar.gz compiler-rt-96a575f05b2a45774170a118ea69ddae3659b645.tar.bz2 compiler-rt-96a575f05b2a45774170a118ea69ddae3659b645.tar.xz |
[asan] Fix deadlock in stack unwinder on android/x86.
Fixes PR17116.
Patch by 林作健 (manjian2006 at gmail.com).
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190590 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_thread.h')
-rw-r--r-- | lib/asan/asan_thread.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/asan/asan_thread.h b/lib/asan/asan_thread.h index 88b7844d..a17a7b4d 100644 --- a/lib/asan/asan_thread.h +++ b/lib/asan/asan_thread.h @@ -87,11 +87,17 @@ class AsanThread { return fake_stack_; } + // True is this thread is currently unwinding stack (i.e. collecting a stack + // trace). Used to prevent deadlocks on platforms where libc unwinder calls + // malloc internally. See PR17116 for more details. + bool isUnwinding() const { return unwinding; } + void setUnwinding(bool b) { unwinding = b; } + AsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; } AsanStats &stats() { return stats_; } private: - AsanThread() {} + AsanThread() : unwinding(false) {} void SetThreadStackAndTls(); void ClearShadowForThreadStackAndTLS(); AsanThreadContext *context_; @@ -105,6 +111,19 @@ class AsanThread { FakeStack *fake_stack_; AsanThreadLocalMallocStorage malloc_storage_; AsanStats stats_; + bool unwinding; +}; + +// ScopedUnwinding is a scope for stacktracing member of a context +class ScopedUnwinding { + public: + explicit ScopedUnwinding(AsanThread *t) : thread(t) { + t->setUnwinding(true); + } + ~ScopedUnwinding() { thread->setUnwinding(false); } + + private: + AsanThread *thread; }; struct CreateThreadContextArgs { |