Subject: Different SIGSEGV codes (x86 and ppc64le)

From: Breno Leitao <[email-masked]>
Date: Tue, 19 Jan 2016 18:49:25 -0200

During some debugging, we found that during a stack overflow, the SIGSEGV code
returned is different on Power and Intel.

We were able to narrow down the test case to the follow simple code:

  https://github.com/leitao/stack/blob/master/overflow.c

On Power, the SIGSEV si->si_code is 2 (SEGV_ACCERR) , meaning "access error". On
the other way around, the same test on x86 returns si->si_code = 1 (SEGV_MAPERR),
meaning "invalid permission". Any idea why such difference?

Example:

Power
-----
  $  gcc overflow.c
  $  ./a.out
  Got SIGSEGV(2) at address: 0x3fffdd90ffe0

x86
---
  $ gcc overflow.c
  $ ./a.out
  Got SIGSEGV(1) at address: 0x7fff9f089fe8

Thank you!
Breno