[compiler-rt] r191004 - [asan] fix one more async-signal-safety issue with use-after-return

Kostya Serebryany kcc at google.com
Thu Sep 19 07:59:53 PDT 2013


Author: kcc
Date: Thu Sep 19 09:59:52 2013
New Revision: 191004

URL: http://llvm.org/viewvc/llvm-project?rev=191004&view=rev
Log:
[asan] fix one more async-signal-safety issue with use-after-return

Modified:
    compiler-rt/trunk/lib/asan/asan_thread.cc
    compiler-rt/trunk/lib/asan/asan_thread.h

Modified: compiler-rt/trunk/lib/asan/asan_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread.cc?rev=191004&r1=191003&r2=191004&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_thread.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_thread.cc Thu Sep 19 09:59:52 2013
@@ -174,10 +174,10 @@ thread_return_t AsanThread::ThreadStart(
 }
 
 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;

Modified: compiler-rt/trunk/lib/asan/asan_thread.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread.h?rev=191004&r1=191003&r2=191004&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_thread.h (original)
+++ compiler-rt/trunk/lib/asan/asan_thread.h Thu Sep 19 09:59:52 2013
@@ -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_;
 





More information about the llvm-commits mailing list