Skip to content

Commit 94d36fb

Browse files
nsrip-ddgopherbot
authored andcommitted
runtime: zero saved frame pointer when reusing goroutine stack on arm64
When a goroutine stack is reused on arm64, the spot on the stack where the "caller's" frame pointer goes for the topmost frame should be explicitly zeroed. Otherwise, the frame pointer check in adjustframe with debugCheckBP enabled will fail on the topmost frame of a call stack the first time a reused stack is grown. Updates #39524, #58432 Change-Id: Ic1210dc005e3ecdbf9cd5d7b98846566e56df8f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/481636 Reviewed-by: Felix Geisendörfer <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]>
1 parent a274b30 commit 94d36fb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/runtime/proc.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -4540,12 +4540,14 @@ func newproc1(fn *funcval, callergp *g, callerpc uintptr) *g {
45404540
totalSize := uintptr(4*goarch.PtrSize + sys.MinFrameSize) // extra space in case of reads slightly beyond frame
45414541
totalSize = alignUp(totalSize, sys.StackAlign)
45424542
sp := newg.stack.hi - totalSize
4543-
spArg := sp
45444543
if usesLR {
45454544
// caller's LR
45464545
*(*uintptr)(unsafe.Pointer(sp)) = 0
45474546
prepGoExitFrame(sp)
4548-
spArg += sys.MinFrameSize
4547+
}
4548+
if GOARCH == "arm64" {
4549+
// caller's FP
4550+
*(*uintptr)(unsafe.Pointer(sp - goarch.PtrSize)) = 0
45494551
}
45504552

45514553
memclrNoHeapPointers(unsafe.Pointer(&newg.sched), unsafe.Sizeof(newg.sched))

0 commit comments

Comments
 (0)