[PATCH] D46626: [asan] Initialize fake stack during thread init
Walter Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 8 20:48:02 PDT 2018
waltl created this revision.
waltl added reviewers: vitalybuka, eugenis, alekseyshl.
Herald added a subscriber: kubamracek.
If detect-stack-use-after-return is on, initialize fake stack during
AsanThread::Init(), rather than lazily. This is required on Myriad.
>From kcc: "There used to be a reason why this was done lazily, but I
don't remember if we still have that reason." Tested on x86.
Repository:
rL LLVM
https://reviews.llvm.org/D46626
Files:
compiler-rt/lib/asan/asan_thread.cc
compiler-rt/lib/asan/asan_thread.h
Index: compiler-rt/lib/asan/asan_thread.h
===================================================================
--- compiler-rt/lib/asan/asan_thread.h
+++ compiler-rt/lib/asan/asan_thread.h
@@ -119,8 +119,6 @@
return nullptr;
if (atomic_load(&stack_switching_, memory_order_relaxed))
return nullptr;
- if (!has_fake_stack())
- return AsyncSignalSafeLazyInitFakeStack();
return fake_stack_;
}
Index: compiler-rt/lib/asan/asan_thread.cc
===================================================================
--- compiler-rt/lib/asan/asan_thread.cc
+++ compiler-rt/lib/asan/asan_thread.cc
@@ -229,13 +229,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_,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46626.145857.patch
Type: text/x-patch
Size: 1379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180509/6704eb41/attachment.bin>
More information about the llvm-commits
mailing list