From 48f32510dacd0f4a205286b06f6fff9e1f5f7335 Mon Sep 17 00:00:00 2001 From: Marcin Koscielnicki Date: Mon, 18 Apr 2016 09:01:19 +0000 Subject: [PATCH] [asan] [SystemZ] Add slop for stack address detection. On s390, siginfo reports the faulting address with page granularity - we need to mask off the low bits of sp before comparison. Differential Revision: http://reviews.llvm.org/D19112 llvm-svn: 266593 --- compiler-rt/lib/asan/asan_posix.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler-rt/lib/asan/asan_posix.cc b/compiler-rt/lib/asan/asan_posix.cc index 9e01bcd091bf..f463c5a637c8 100644 --- a/compiler-rt/lib/asan/asan_posix.cc +++ b/compiler-rt/lib/asan/asan_posix.cc @@ -43,7 +43,15 @@ void AsanOnDeadlySignal(int signo, void *siginfo, void *context) { // Access at a reasonable offset above SP, or slightly below it (to account // for x86_64 or PowerPC redzone, ARM push of multiple registers, etc) is // probably a stack overflow. +#ifdef __s390__ + // On s390, the fault address in siginfo points to start of the page, not + // to the precise word that was accessed. Mask off the low bits of sp to + // take it into account. + bool IsStackAccess = sig.addr >= (sig.sp & ~0xFFF) && + sig.addr < sig.sp + 0xFFFF; +#else bool IsStackAccess = sig.addr + 512 > sig.sp && sig.addr < sig.sp + 0xFFFF; +#endif #if __powerpc__ // Large stack frames can be allocated with e.g.