-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
The framepointer check from go vet is currently quite conservative. Since Go 1.21, frame pointers have become more load-bearing in the Go runtime. They're now used on amd64 and arm64 to collect call stacks for the execution tracer and the block & mutex profilers. Now, frame pointer bugs can crash Go programs, whereas before they would merely result in broken call stacks for external profilers like Linux perf.
For example, #69629 was ultimately caused by a bug in programatically-generated amd64 assembly which clobbered the frame pointer register. As of Go 1.23.2, go vet misses that frame pointer bug. This is because the frame pointer is clobbered after a branch instruction, and the check aborts if it reaches a branch.
I think we should try to expand the number of bugs the framepointer check can catch. For example, arm64 support would be good. We also might be able to drop that branch check, or flag assembly that writes to rbp without a push rbp near the beginning and a pop rbp before returning. These kinds of ideas should of course be tested against existing open source Go assembly code, since I assume there is little (if any?) tolerance for false positives in go vet tools.