golang/go
View on GitHubcmd/asm: don't allow writes outside of a function's stack frame
Open
#79062 opened on Apr 30, 2026
NeedsInvestigationToolProposalcompiler/runtimehelp wanted
Description
Go version
go1.26.2 linux/amd64
Output of go env in your module/workspace:
n/a
What did you do?
Wrote the following amd64 assembly function:
#include "textflag.h"
TEXT ·clobber(SB),NOSPLIT,$8-0
MOVQ $42, 8(SP)
RET
What did you see happen?
It compiles.
What did you expect to see?
I think it shouldn't compile. The function declares an 8 byte stack frame, and that stack write is outside of the declared stack frame. Such a write was the cause of https://github.com/golang/go/issues/77250. In that issue, an assembly function overwrote the frame pointer saved at the top of the stack frame, leading to an execution tracer crash when the function returned. The assembler seems to accept any value for the offset of the SP virtual register. I think the same thing might apply to the FP pseudo-register: the function declares the amount of space for arguments and any read outside of that space is probably a bug.