aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime2.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2026-01-12 15:05:24 -0800
committerGopher Robot <gobot@golang.org>2026-03-06 10:08:12 -0800
commit50d988e4e037d9d41ac223a62706dfea47a100e4 (patch)
treecccebaec15e091c18a1da50a0c0253c9809642be /src/runtime/runtime2.go
parentbf84b002d64d0b150818268e520fee0172a5c462 (diff)
downloadgo-50d988e4e037d9d41ac223a62706dfea47a100e4.tar.xz
runtime: when panicking, skip ahead to previous panic
While looking up the stack for a defer to run, if we come across a panic frame we can skip ahead (up) to where the previous panic was looking for a defer to run. Switch from keeping LR (the caller's pc) to PC (the frame's PC). Seems easier to reason about. Fixes #77062 Change-Id: Idb39411ebad8c072c8f65c62a518da848bddbd61 Reviewed-on: https://go-review.googlesource.com/c/go/+/738041 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/runtime/runtime2.go')
-rw-r--r--src/runtime/runtime2.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index 95dc834717..9fec6c6a1e 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -1177,16 +1177,17 @@ type _panic struct {
link *_panic // link to earlier panic
// startPC and startSP track where _panic.start was called.
+ // (These are the SP and PC of the gopanic frame itself.)
startPC uintptr
startSP unsafe.Pointer
// The current stack frame that we're running deferred calls for.
+ pc uintptr
sp unsafe.Pointer
- lr uintptr
fp unsafe.Pointer
// retpc stores the PC where the panic should jump back to, if the
- // function last returned by _panic.next() recovers the panic.
+ // function last returned by _panic.nextDefer() recovers the panic.
retpc uintptr
// Extra state for handling open-coded defers.