[PATCH] D46626: [asan] Initialize fake stack during thread init

Walter Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 10 13:12:53 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL332033: [asan] Initialize fake stack during thread init (authored by waltl, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D46626?vs=145857&id=146207#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46626

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


Index: compiler-rt/trunk/lib/asan/asan_thread.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_thread.cc
+++ compiler-rt/trunk/lib/asan/asan_thread.cc
@@ -221,13 +221,15 @@
 void AsanThread::Init(const InitOptions *options) {
   next_stack_top_ = next_stack_bottom_ = 0;
   atomic_store(&stack_switching_, false, memory_order_release);
-  fake_stack_ = nullptr;  // Will be initialized lazily if needed.
   CHECK_EQ(this->stack_size(), 0U);
   SetThreadStackAndTls(options);
   CHECK_GT(this->stack_size(), 0U);
   CHECK(AddrIsInMem(stack_bottom_));
   CHECK(AddrIsInMem(stack_top_ - 1));
   ClearShadowForThreadStackAndTLS();
+  fake_stack_ = nullptr;
+  if (__asan_option_detect_stack_use_after_return)
+    AsyncSignalSafeLazyInitFakeStack();
   int local = 0;
   VReport(1, "T%d: stack [%p,%p) size 0x%zx; local=%p\n", tid(),
           (void *)stack_bottom_, (void *)stack_top_, stack_top_ - stack_bottom_,
Index: compiler-rt/trunk/lib/asan/asan_thread.h
===================================================================
--- compiler-rt/trunk/lib/asan/asan_thread.h
+++ compiler-rt/trunk/lib/asan/asan_thread.h
@@ -117,8 +117,6 @@
       return nullptr;
     if (atomic_load(&stack_switching_, memory_order_relaxed))
       return nullptr;
-    if (!has_fake_stack())
-      return AsyncSignalSafeLazyInitFakeStack();
     return fake_stack_;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46626.146207.patch
Type: text/x-patch
Size: 1415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180510/1f655a90/attachment.bin>


More information about the llvm-commits mailing list