runtime: clear frame pointer in morestack

Corollary to CL 669615.

morestack uses the frame pointer from g0.sched.bp. This doesn't really
make any sense. morestack wasn't called by whatever used g0 last, so at
best unwinding will get misleading results.

For #63630.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-arm64-longtest
Change-Id: I6a6a636c3a2994eb88f890c506c96fd899e993a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/669616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nick Ripley <nick.ripley@datadoghq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Michael Pratt 2025-05-02 14:58:42 -04:00 committed by Gopher Robot
parent 739fb752e3
commit 93fb2c9074
2 changed files with 2 additions and 2 deletions

View File

@ -616,7 +616,7 @@ TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0
MOVQ m_g0(BX), BX MOVQ m_g0(BX), BX
MOVQ BX, g(CX) MOVQ BX, g(CX)
MOVQ (g_sched+gobuf_sp)(BX), SP MOVQ (g_sched+gobuf_sp)(BX), SP
MOVQ (g_sched+gobuf_bp)(BX), BP MOVQ $0, BP // clear frame pointer, as caller may execute on another M
CALL runtime·newstack(SB) CALL runtime·newstack(SB)
CALL runtime·abort(SB) // crash if newstack returns CALL runtime·abort(SB) // crash if newstack returns
RET RET

View File

@ -387,7 +387,7 @@ TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0
BL runtime·save_g(SB) BL runtime·save_g(SB)
MOVD (g_sched+gobuf_sp)(g), R0 MOVD (g_sched+gobuf_sp)(g), R0
MOVD R0, RSP MOVD R0, RSP
MOVD (g_sched+gobuf_bp)(g), R29 MOVD $0, R29 // clear frame pointer, as caller may execute on another M
MOVD.W $0, -16(RSP) // create a call frame on g0 (saved LR; keep 16-aligned) MOVD.W $0, -16(RSP) // create a call frame on g0 (saved LR; keep 16-aligned)
BL runtime·newstack(SB) BL runtime·newstack(SB)