aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorNick Ripley <nick.ripley@datadoghq.com>2023-04-03 09:32:05 -0400
committerGopher Robot <gobot@golang.org>2023-08-15 13:58:27 +0000
commit94d36fbc4acdbcff5d4d7ad3869f285294c4181c (patch)
treec6fdb639f95c461959b9a75f528094925dc350cd /src/runtime/proc.go
parenta274b3003b8d03a0384a5bbbf6bfe459fd2c4787 (diff)
downloadgo-94d36fbc4acdbcff5d4d7ad3869f285294c4181c.tar.xz
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>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index fafab7f58c..8fab6d46d1 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -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 = alignUp(totalSize, sys.StackAlign)
sp := newg.stack.hi - totalSize
- spArg := sp
if usesLR {
// caller's LR
*(*uintptr)(unsafe.Pointer(sp)) = 0
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))