[PATCH] D58940: [Sanitizer] Only unwind when it is safe to do so
Julian Lettner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 4 17:17:36 PST 2019
yln created this revision.
yln added a reviewer: vitalybuka.
Herald added subscribers: llvm-commits, Sanitizers, kubamracek.
Herald added projects: Sanitizers, LLVM.
ScopedUnwinding and AsanThread::isUnwinding were introduced to
> "Fix deadlock in stack unwinder on android/x86" on platforms where
> libc unwinder calls malloc internally.
https://github.com/llvm/llvm-project/commit/58dbe0623051f1bb49256693e54b4e29f7db5faf
The current state of the code only protects the fast unwinder, which is
not affected by this. Only SlowUnwind calls out to `_Unwind_Backtrace`.
So we are in a situation where the code that should be protected isn't,
and code that doesn't need to be protected is.
Since this hasn't been causing issues, we don't even know if it strictly
required anymore. But let's be conservative and make sure at least also
SlowUnwind is protected.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D58940
Files:
compiler-rt/lib/asan/asan_stack.cc
Index: compiler-rt/lib/asan/asan_stack.cc
===================================================================
--- compiler-rt/lib/asan/asan_stack.cc
+++ compiler-rt/lib/asan/asan_stack.cc
@@ -35,10 +35,12 @@
if (UNLIKELY(!asan_inited)) return;
AsanThread *t = GetCurrentThread();
- if (t && !t->isUnwinding() && WillUseFastUnwind(request_fast)) {
+ if (!t || t->isUnwinding()) return;
+
+ ScopedUnwinding unwind_scope(t);
+ if (WillUseFastUnwind(request_fast)) {
uptr top = t->stack_top();
uptr bottom = t->stack_bottom();
- ScopedUnwinding unwind_scope(t);
if (!SANITIZER_MIPS || IsValidFrame(bp, top, bottom)) {
UnwindFast(pc, bp, top, bottom, max_depth);
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58940.189243.patch
Type: text/x-patch
Size: 710 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190305/a185a61c/attachment.bin>
More information about the llvm-commits
mailing list