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 (macOS): misaligned SP in the prologue of a function with a frame > 512 bytes that passes 1–8 bytes of stack arguments → SIGBUS #614
Versions: CompCert 3.18 (release tag v3.18, via opam coq-compcert 3.18; the tag's VERSION file, and therefore ccomp -version, still say 3.17), target aarch64-macos, macOS 26.7.1 on Apple Silicon (arm64). The Pallocframe expansion in aarch64/Asmexpand.ml on current master looks the same.
With 11 arguments (more than 8 bytes of stack arguments) or a small frame, it runs correctly.
Generated prologue of f (ccomp -S):
_f:
mov x15, sp
sub sp, sp, #8192
sub sp, sp, #3832
stp x15, x30, [sp, #0]
The frame is 12024 bytes, not a multiple of 16: sp is misaligned when the frame is set up and when g is called. In Asmexpand.ml, Pallocframe(sz, linkofs, retaddrofs) subtracts sz1 = sz - linkofs first (the > 512 branch: expand_addimm64 XSP XSP (-sz1), then stp x15, x30, [sp]) and the remaining linkofs bytes afterwards. When the outgoing arguments make linkofs 8, sz1 is ≡ 8 (mod 16) and the intermediate sp (and the stp through it) is misaligned. macOS enforces 16-byte SP alignment and traps.
Expected:sp stays 16-byte aligned at every point where it is used as a base register (AAPCS64 §6.2.2; required on Darwin).
Context: found while building a CompCert/VST-verified filesystem kernel. A 9-argument function that had been inlined became a real call after it was exported. We work around it by never passing more than 8 integer arguments from code compiled with CompCert.
Thanks for the report. Since #583, AArch64 stack frames can be allocated in two steps: first, everything except the outgoing arguments area; then the outgoing arguments area. As shown in this example, even though the whole frame size is a multiple of 16, the sizes of the two parts may not, causing the SP misalignment issue observed. The simple fix is to 16-align the outgoing arguments area of the stack frame in aarch64/Stacklayout.v.
Activity
xavierleroy commentedon Nov 16, 2026
Thanks for the report. Since #583, AArch64 stack frames can be allocated in two steps: first, everything except the outgoing arguments area; then the outgoing arguments area. As shown in this example, even though the whole frame size is a multiple of 16, the sizes of the two parts may not, causing the SP misalignment issue observed. The simple fix is to 16-align the outgoing arguments area of the stack frame in aarch64/Stacklayout.v.
AArch64: make sure SP is 16-aligned at all times during Pallocframe