]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.19] runtime: don't jump stack if at entry of systemstack
authorCherry Mui <cherryyz@google.com>
Fri, 30 Sep 2022 23:01:09 +0000 (19:01 -0400)
committerMichael Knyszek <mknyszek@google.com>
Wed, 9 Nov 2022 18:44:56 +0000 (18:44 +0000)
commitec6510887c2ce7571c78ae497ccf9ad334fa3145
treeecc8ae0619a37c6b3d5566f460eb50427a4a7282
parent9e0b6c11115ce187f6c526858904204c3efa2ce2
[release-branch.go1.19] runtime: don't jump stack if at entry of systemstack

The traceback code has special "jump stack" logic, to trace back
stack switches through systemstack. If we're at the entry of
systemstack, the stack switch hasn't happened, so don't jump to
user stack.

The jump stack logic is only used if we're on the g0 stack. It can
happen that we're at the entry of a recursive systemstack call on
the g0 stack. In we jump stack here, there will be two problems:
1. There are frames between entering the g0 stack and this
   recursive systemstack call. Those frames will be lost.
2. Worse, we switched frame.sp but frame.fp calculation will use
   the entry SP delta (0), which will be wrong, which in turn
   leads wrong frame.lr and things will go off.

For now, don't jump stack if we're at entry of systemstack (SP
delta is 0).

Using a per-PC SPWRITE marker may be a better fix. If we haven't
written the SP, we haven't switched the stack so we can just
unwind like a normal function.

Updates #55851.
Fixes #56636.

Change-Id: I2b624c8c086b235b34d9c7d3cebd4a37264f00f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/437299
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
(cherry picked from commit 500bc6b8056ee2eaf7640610a48ffa00bdd896a5)
Reviewed-on: https://go-review.googlesource.com/c/go/+/448516
src/runtime/traceback.go