[compiler-rt] 249d9b0 - Revert "Remove obsolete call to AsyncSignalSafeLazyInitiFakeStack."

Kevin Athey via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 17 09:27:09 PDT 2021


Author: Kevin Athey
Date: 2021-06-17T09:27:02-07:00
New Revision: 249d9b051f92d1a323b3dd477f95133648df4774

URL: https://github.com/llvm/llvm-project/commit/249d9b051f92d1a323b3dd477f95133648df4774
DIFF: https://github.com/llvm/llvm-project/commit/249d9b051f92d1a323b3dd477f95133648df4774.diff

LOG: Revert "Remove obsolete call to AsyncSignalSafeLazyInitiFakeStack."

This reverts commit 07481b37961f5b9a670c924367d2ead2e3c32b86.

Differential Revision: https://reviews.llvm.org/D104469

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_thread.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_thread.cpp b/compiler-rt/lib/asan/asan_thread.cpp
index ca5b8363be22e..7099850254875 100644
--- a/compiler-rt/lib/asan/asan_thread.cpp
+++ b/compiler-rt/lib/asan/asan_thread.cpp
@@ -240,6 +240,17 @@ void AsanThread::Init(const InitOptions *options) {
   }
   ClearShadowForThreadStackAndTLS();
   fake_stack_ = nullptr;
+  if (__asan_option_detect_stack_use_after_return &&
+      tid() == GetCurrentTidOrInvalid()) {
+    // AsyncSignalSafeLazyInitFakeStack makes use of threadlocals and must be
+    // called from the context of the thread it is initializing, not its parent.
+    // Most platforms call AsanThread::Init on the newly-spawned thread, but
+    // Fuchsia calls this function from the parent thread.  To support that
+    // approach, we avoid calling AsyncSignalSafeLazyInitFakeStack here; it will
+    // be called by the new thread when it first attempts to access the fake
+    // stack.
+    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_,


        


More information about the llvm-commits mailing list