mirror of
https://github.com/golang/go
synced 2024-11-17 17:34:46 -07:00
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 <felix.geisendoerfer@datadoghq.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
parent
a274b3003b
commit
94d36fbc4a
@ -4540,12 +4540,14 @@ func newproc1(fn *funcval, callergp *g, callerpc uintptr) *g {
|
|||||||
totalSize := uintptr(4*goarch.PtrSize + sys.MinFrameSize) // extra space in case of reads slightly beyond frame
|
totalSize := uintptr(4*goarch.PtrSize + sys.MinFrameSize) // extra space in case of reads slightly beyond frame
|
||||||
totalSize = alignUp(totalSize, sys.StackAlign)
|
totalSize = alignUp(totalSize, sys.StackAlign)
|
||||||
sp := newg.stack.hi - totalSize
|
sp := newg.stack.hi - totalSize
|
||||||
spArg := sp
|
|
||||||
if usesLR {
|
if usesLR {
|
||||||
// caller's LR
|
// caller's LR
|
||||||
*(*uintptr)(unsafe.Pointer(sp)) = 0
|
*(*uintptr)(unsafe.Pointer(sp)) = 0
|
||||||
prepGoExitFrame(sp)
|
prepGoExitFrame(sp)
|
||||||
spArg += sys.MinFrameSize
|
}
|
||||||
|
if GOARCH == "arm64" {
|
||||||
|
// caller's FP
|
||||||
|
*(*uintptr)(unsafe.Pointer(sp - goarch.PtrSize)) = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
memclrNoHeapPointers(unsafe.Pointer(&newg.sched), unsafe.Sizeof(newg.sched))
|
memclrNoHeapPointers(unsafe.Pointer(&newg.sched), unsafe.Sizeof(newg.sched))
|
||||||
|
Loading…
Reference in New Issue
Block a user