[compiler-rt] eca4b40 - [Sanitizer] Fix segfaults during unwinding on SystemZ

Ilya Leoshkevich via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 13:24:48 PDT 2020


Author: Ilya Leoshkevich
Date: 2020-08-12T22:24:32+02:00
New Revision: eca4b4007d6bafd5fc4be24e2b275ffc22841c63

URL: https://github.com/llvm/llvm-project/commit/eca4b4007d6bafd5fc4be24e2b275ffc22841c63
DIFF: https://github.com/llvm/llvm-project/commit/eca4b4007d6bafd5fc4be24e2b275ffc22841c63.diff

LOG: [Sanitizer] Fix segfaults during unwinding on SystemZ

Every now and then SystemZ programs built with ASan crash with

    ERROR: AddressSanitizer: stack-overflow on address 0x040000000000

for no apparent reason. The problem is that
BufferedStackTrace::UnwindFast() is specialized for SystemZ: it takes
register 14 from the frame, however, IsValidFrame() is not
specialized, and does not guarantee that frame[14] is going to be a
valid memory access.

Fix by introducing per-arch kFrameSize and using it in IsValidFrame().

Reviewed By: uweigand

Differential Revision: https://reviews.llvm.org/D85822

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
index f1f29e9f32ee..4162b58a867d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
@@ -143,9 +143,17 @@ struct BufferedStackTrace : public StackTrace {
   friend class FastUnwindTest;
 };
 
+#if defined(__s390x__)
+static const uptr kFrameSize = 160;
+#elif defined(__s390__)
+static const uptr kFrameSize = 96;
+#else
+static const uptr kFrameSize = 2 * sizeof(uhwptr);
+#endif
+
 // 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);
+  return frame > stack_bottom && frame < stack_top - kFrameSize;
 }
 
 }  // namespace __sanitizer


        


More information about the llvm-commits mailing list