From 92e12a694d81bfc1e585d3cff9083a9c63f84883 Mon Sep 17 00:00:00 2001 From: Sagar Thakur Date: Wed, 18 May 2016 06:09:26 +0000 Subject: [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/trunk@269882 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/sanitizer_common/sanitizer_stacktrace.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/sanitizer_common/sanitizer_stacktrace.h') 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 -- cgit v1.2.1