]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.21] runtime: restore caller's frame pointer when recovering from...
authorNick Ripley <nick.ripley@datadoghq.com>
Fri, 4 Aug 2023 21:31:43 +0000 (17:31 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 30 Aug 2023 22:33:03 +0000 (22:33 +0000)
commit8dc6ad1c61cd5cea66de62dc0308e9ce22a05b88
tree75cbf2450aacaf74688c0bb28f9f93f64cda3f20
parent06df3292a88929cde5fb054ae8a84e26a625e603
[release-branch.go1.21] runtime: restore caller's frame pointer when recovering from panic

When recovering from a panic, restore the caller's frame pointer before
returning control to the caller. Otherwise, if the function proceeds to
run more deferred calls before returning, the deferred functions will
get invalid frame pointers pointing to an address lower in the stack.
This can cause frame pointer unwinding to crash, such as if an execution
trace event is recorded during the deferred call on architectures which
support frame pointer unwinding.

Original CL by Nick Ripley, includes fix from CL 523697, and includes a
test update from CL 524315.

This CL also deviates from the original fix by doing some extra
computation to figure out the fp from the sp, since we don't have the fp
immediately available to us in `recovery` on the Go 1.21 branch, and it
would probably be complicated to plumb that through its caller.

For #61766
Fixes #62046

Change-Id: I5a99ca4f909f6b6e209a330d595d1c99987d4359
Reviewed-on: https://go-review.googlesource.com/c/go/+/523698
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/callers_test.go
src/runtime/export_test.go
src/runtime/panic.go