You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AArch64: misaligned SP in the prologue of large frames (SIGBUS on Linux) #616
Since #583 (commit 0ef26da), the AArch64 expansion of Pallocframe in aarch64/Asmexpand.ml can store X15 and X30 through an SP that is misaligned by 8. Linux enables SP alignment checking at EL0, so the store raises SIGBUS.
The back link's offset linkofs is olink := align (4 * b.(bound_outgoing)) 8 (aarch64/Stacklayout.v), a multiple of 8 but not always of 16, while the frame size sz is a multiple of 16. When sz1 = sz - linkofs exceeds 512, the expansion emits
mov x15, sp
sub sp, sp, #sz1
stp x15, x30, [sp]
When the outgoing arguments fill an odd number of 8-byte slots, sz1 is 8 modulo 16, and the stp uses a misaligned SP as its base. When sz1 is at most 512, the pre-indexed stp x15, x30, [sp, #-sz1]! has the aligned SP as its base, and no access uses the misaligned SP it writes back before the next sub restores alignment.
Reproducer (CompCert 3.18, aarch64-linux, Linux 7.0, Cortex-X925/A725):
ccomp -o repro repro.c && ./repro ends with "Bus error". The call to g passes one double on the stack, so linkofs is 8, and the prologue of f is mov x15, sp; sub sp, sp, #616; stp x15, x30, [sp]. With buf[300], sz1 is 328, the pre-indexed form is used, and the program prints 37.
This change rounds the first adjustment up to a multiple of 16 and stores the pair at the difference:
Activity
jsmorph commentedon Nov 17, 2026
Duplicate of #614. The same misaligned SP raises SIGBUS on Linux/aarch64, which checks SP alignment at EL0.