Index: lib/asan/asan_posix.cc =================================================================== --- lib/asan/asan_posix.cc +++ lib/asan/asan_posix.cc @@ -44,11 +44,32 @@ // 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. + bool IsStackAccess = addr + 512 > sp && addr < sp + 0xFFFF; + +#if __powerpc64__ + // Large stack frames can be allocated with e.g. + // lis r0,-10000 + // stdux r1,r1,r0 # store sp to [sp-10000] and update sp by -10000 + // If the store faults then sp will not have been updated, so test above + // will not work, becase the fault address will be more than just "slightly" + // below sp. + if (!IsStackAccess && IsAccessibleMemoryRange(pc, 4)) { + unsigned inst = *(unsigned *)pc; + unsigned ra = (inst >> 16) & 0x1F; + unsigned opcd = inst >> 26; + unsigned xo = (inst >> 1) & 0x3FF; + // Check for store-with-update to r1. + if (ra == 1 && + (opcd == 37 || opcd == 39 || opcd == 45 || opcd == 62 || + (opcd == 31 && (xo == 181 || xo == 183 || xo == 247 || xo == 439)))) + IsStackAccess = true; + } +#endif // __powerpc64__ + // We also check si_code to filter out SEGV caused by something else other // then hitting the guard page or unmapped memory, like, for example, // unaligned memory access. - if (addr + 512 > sp && addr < sp + 0xFFFF && - (code == si_SEGV_MAPERR || code == si_SEGV_ACCERR)) + if (IsStackAccess && (code == si_SEGV_MAPERR || code == si_SEGV_ACCERR)) ReportStackOverflow(pc, sp, bp, context, addr); else ReportSIGSEGV("SEGV", pc, sp, bp, context, addr);