summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSagar Thakur <sagar.thakur@imgtec.com>2016-05-25 05:57:29 +0000
committerSagar Thakur <sagar.thakur@imgtec.com>2016-05-25 05:57:29 +0000
commit7c72fe86ac306c4b73dcd98ed5b32cfe019ba888 (patch)
treec1d2d20a0bef55e49aebf103c5e9a4cdcabadd0f
parent723f5cd118b29379d3f6431257c7e4da922915af (diff)
downloadcompiler-rt-7c72fe86ac306c4b73dcd98ed5b32cfe019ba888.tar.gz
Merging r269882:
------------------------------------------------------------------------ r269882 | slthakur | 2016-05-18 11:39:26 +0530 (Wed, 18 May 2016) | 7 lines [LSAN] Fix test swapcontext.cc on MIPS There is no frame validity check in the slow unwinder like there is in the fast unwinder due to which lsan reports a leak even for heap allocated coroutine in the test swapcontext.cc. Since mips/linux uses slow unwindwer instead of fast unwinder, the test fails for mips/linux. Therefore adding the checks before unwinding fixes the test for mips/linux. Reviewed by aizatsky. Differential: http://reviews.llvm.org/D19961 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/branches/release_38@270672 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/asan/asan_stack.h5
-rw-r--r--lib/lsan/lsan.h7
-rw-r--r--lib/sanitizer_common/sanitizer_stacktrace.cc5
-rw-r--r--lib/sanitizer_common/sanitizer_stacktrace.h5
4 files changed, 14 insertions, 8 deletions
diff --git a/lib/asan/asan_stack.h b/lib/asan/asan_stack.h
index 5c5181509..cc95e0f30 100644
--- a/lib/asan/asan_stack.h
+++ b/lib/asan/asan_stack.h
@@ -48,7 +48,10 @@ void GetStackTraceWithPcBpAndContext(BufferedStackTrace *stack, uptr max_depth,
uptr stack_top = t->stack_top();
uptr stack_bottom = t->stack_bottom();
ScopedUnwinding unwind_scope(t);
- stack->Unwind(max_depth, pc, bp, context, stack_top, stack_bottom, fast);
+ if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) {
+ stack->Unwind(max_depth, pc, bp, context, stack_top, stack_bottom,
+ fast);
+ }
} else if (!t && !fast) {
/* If GetCurrentThread() has failed, try to do slow unwind anyways. */
stack->Unwind(max_depth, pc, bp, context, 0, 0, false);
diff --git a/lib/lsan/lsan.h b/lib/lsan/lsan.h
index 53783cdc9..ec5eb93dc 100644
--- a/lib/lsan/lsan.h
+++ b/lib/lsan/lsan.h
@@ -24,8 +24,11 @@
stack_top = t->stack_end(); \
stack_bottom = t->stack_begin(); \
} \
- stack.Unwind(max_size, StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), \
- /* context */ 0, stack_top, stack_bottom, fast); \
+ if (!SANITIZER_MIPS || \
+ IsValidFrame(GET_CURRENT_FRAME(), stack_top, stack_bottom)) { \
+ stack.Unwind(max_size, StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), \
+ /* context */ 0, stack_top, stack_bottom, fast); \
+ } \
}
#define GET_STACK_TRACE_FATAL \
diff --git a/lib/sanitizer_common/sanitizer_stacktrace.cc b/lib/sanitizer_common/sanitizer_stacktrace.cc
index 7862575b3..04da55fc9 100644
--- a/lib/sanitizer_common/sanitizer_stacktrace.cc
+++ b/lib/sanitizer_common/sanitizer_stacktrace.cc
@@ -40,11 +40,6 @@ void BufferedStackTrace::Init(const uptr *pcs, uptr cnt, uptr extra_top_pc) {
top_frame_bp = 0;
}
-// Check if given pointer points into allocated stack area.
-static inline bool IsValidFrame(uptr frame, uptr stack_top, uptr stack_bottom) {
- return frame > stack_bottom && frame < stack_top - 2 * sizeof (uhwptr);
-}
-
// In GCC on ARM bp points to saved lr, not fp, so we should check the next
// cell in stack to be a saved frame pointer. GetCanonicFrame returns the
// pointer to saved frame pointer in any case.
diff --git a/lib/sanitizer_common/sanitizer_stacktrace.h b/lib/sanitizer_common/sanitizer_stacktrace.h
index 969cedb16..90142dffd 100644
--- a/lib/sanitizer_common/sanitizer_stacktrace.h
+++ b/lib/sanitizer_common/sanitizer_stacktrace.h
@@ -110,6 +110,11 @@ struct BufferedStackTrace : public StackTrace {
void operator=(const BufferedStackTrace &);
};
+// Check if given pointer points into allocated stack area.
+static inline bool IsValidFrame(uptr frame, uptr stack_top, uptr stack_bottom) {
+ return frame > stack_bottom && frame < stack_top - 2 * sizeof (uhwptr);
+}
+
} // namespace __sanitizer
// Use this macro if you want to print stack trace with the caller