[llvm-branch-commits] [compiler-rt-branch] r270672 - Merging r269882:

Sagar Thakur via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue May 24 23:00:42 PDT 2016


Author: slthakur
Date: Wed May 25 00:57:29 2016
New Revision: 270672

URL: http://llvm.org/viewvc/llvm-project?rev=270672&view=rev
Log:
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

------------------------------------------------------------------------

Modified:
    compiler-rt/branches/release_38/   (props changed)
    compiler-rt/branches/release_38/lib/asan/asan_stack.h
    compiler-rt/branches/release_38/lib/lsan/lsan.h
    compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stacktrace.cc
    compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stacktrace.h

Propchange: compiler-rt/branches/release_38/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 25 00:57:29 2016
@@ -1 +1 @@
-/compiler-rt/trunk:258916,259755,260669,260839,260946,261073,261142,261148,261193,261263,261513,261721,261723,261837,261980,261982,262209,262302-262303,262690,263001,263218,267674
+/compiler-rt/trunk:258916,259755,260669,260839,260946,261073,261142,261148,261193,261263,261513,261721,261723,261837,261980,261982,262209,262302-262303,262690,263001,263218,267674,269882

Modified: compiler-rt/branches/release_38/lib/asan/asan_stack.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/lib/asan/asan_stack.h?rev=270672&r1=270671&r2=270672&view=diff
==============================================================================
--- compiler-rt/branches/release_38/lib/asan/asan_stack.h (original)
+++ compiler-rt/branches/release_38/lib/asan/asan_stack.h Wed May 25 00:57:29 2016
@@ -48,7 +48,10 @@ void GetStackTraceWithPcBpAndContext(Buf
       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);

Modified: compiler-rt/branches/release_38/lib/lsan/lsan.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/lib/lsan/lsan.h?rev=270672&r1=270671&r2=270672&view=diff
==============================================================================
--- compiler-rt/branches/release_38/lib/lsan/lsan.h (original)
+++ compiler-rt/branches/release_38/lib/lsan/lsan.h Wed May 25 00:57:29 2016
@@ -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 \

Modified: compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stacktrace.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stacktrace.cc?rev=270672&r1=270671&r2=270672&view=diff
==============================================================================
--- compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stacktrace.cc (original)
+++ compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stacktrace.cc Wed May 25 00:57:29 2016
@@ -40,11 +40,6 @@ void BufferedStackTrace::Init(const uptr
   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.

Modified: compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stacktrace.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stacktrace.h?rev=270672&r1=270671&r2=270672&view=diff
==============================================================================
--- compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stacktrace.h (original)
+++ compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stacktrace.h Wed May 25 00:57:29 2016
@@ -110,6 +110,11 @@ struct BufferedStackTrace : public Stack
   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




More information about the llvm-branch-commits mailing list