https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123769
--- Comment #4 from Jim Zatorski <jimzat at gmail dot com> ---
Referring to the first test case:
What I am running into is that when I have multiple lines accessing the X_s
array and this routine gets interrupted, the memory pointed to by [rbp-0x08]
gets overwritten and when execution return to this function, I end up with a
page fault trying to access memory referenced by the messed up pointer.
As you'll notice in TestMain2(), rsp is decremented by 0x20 to protect this
area.
Regardless, all three routines reference rbp-0x08 in response to the line
"X_s[0]=1". In TestMain() and TestMain3() this location is likely to get
stepped on from an interrupt since rsp and rbp are identical.
It's possible that I am misunderstanding something here, but when I run this in
my system the code:
"rax,QWORD PTR [rbp-0x8]
mov BYTE PTR [rax],0x1"
results in a page fault.
Single-stepping through the routine, I see that the memory at rbp-0x8 is
inexplicably changing.