diff --git a/compiler-rt/lib/asan/asan_thread.cc b/compiler-rt/lib/asan/asan_thread.cc index 5c2289491535..16648fe7485a 100644 --- a/compiler-rt/lib/asan/asan_thread.cc +++ b/compiler-rt/lib/asan/asan_thread.cc @@ -174,10 +174,10 @@ thread_return_t AsanThread::ThreadStart(uptr os_id) { } void AsanThread::SetThreadStackAndTls() { - uptr stack_size = 0, tls_size = 0; - GetThreadStackAndTls(tid() == 0, &stack_bottom_, &stack_size, &tls_begin_, + uptr tls_size = 0; + GetThreadStackAndTls(tid() == 0, &stack_bottom_, &stack_size_, &tls_begin_, &tls_size); - stack_top_ = stack_bottom_ + stack_size; + stack_top_ = stack_bottom_ + stack_size_; tls_end_ = tls_begin_ + tls_size; int local; diff --git a/compiler-rt/lib/asan/asan_thread.h b/compiler-rt/lib/asan/asan_thread.h index 00a1233993a5..bd92cfe4c6dd 100644 --- a/compiler-rt/lib/asan/asan_thread.h +++ b/compiler-rt/lib/asan/asan_thread.h @@ -62,7 +62,7 @@ class AsanThread { uptr stack_top() { return stack_top_; } uptr stack_bottom() { return stack_bottom_; } - uptr stack_size() { return stack_top_ - stack_bottom_; } + uptr stack_size() { return stack_size_; } uptr tls_begin() { return tls_begin_; } uptr tls_end() { return tls_end_; } u32 tid() { return context_->tid; } @@ -116,6 +116,9 @@ class AsanThread { void *arg_; uptr stack_top_; uptr stack_bottom_; + // stack_size_ == stack_top_ - stack_bottom_; + // It needs to be set in a async-signal-safe manner. + uptr stack_size_; uptr tls_begin_; uptr tls_end_;