Commit 1f3339f4 authored by Dan Scales's avatar Dan Scales

runtime: fix dumpgoroutine() to deal with open-coded defers

_defer.fn can be nil, so we need to add a check when dumping
_defer.fn.fn.

Fixes #35172

Change-Id: Ic1138be5ec9dce915a87467cfa51ff83acc6e3a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/203697
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 22d37707
...@@ -371,7 +371,12 @@ func dumpgoroutine(gp *g) { ...@@ -371,7 +371,12 @@ func dumpgoroutine(gp *g) {
dumpint(uint64(d.sp)) dumpint(uint64(d.sp))
dumpint(uint64(d.pc)) dumpint(uint64(d.pc))
dumpint(uint64(uintptr(unsafe.Pointer(d.fn)))) dumpint(uint64(uintptr(unsafe.Pointer(d.fn))))
dumpint(uint64(uintptr(unsafe.Pointer(d.fn.fn)))) if d.fn == nil {
// d.fn can be nil for open-coded defers
dumpint(uint64(0))
} else {
dumpint(uint64(uintptr(unsafe.Pointer(d.fn.fn))))
}
dumpint(uint64(uintptr(unsafe.Pointer(d.link)))) dumpint(uint64(uintptr(unsafe.Pointer(d.link))))
} }
for p := gp._panic; p != nil; p = p.link { for p := gp._panic; p != nil; p = p.link {
......
...@@ -824,10 +824,10 @@ type _defer struct { ...@@ -824,10 +824,10 @@ type _defer struct {
// defers. We have only one defer record for the entire frame (which may // defers. We have only one defer record for the entire frame (which may
// currently have 0, 1, or more defers active). // currently have 0, 1, or more defers active).
openDefer bool openDefer bool
sp uintptr // sp at time of defer sp uintptr // sp at time of defer
pc uintptr // pc at time of defer pc uintptr // pc at time of defer
fn *funcval fn *funcval // can be nil for open-coded defers
_panic *_panic // panic that is running defer _panic *_panic // panic that is running defer
link *_defer link *_defer
// If openDefer is true, the fields below record values about the stack // If openDefer is true, the fields below record values about the stack
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment