1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:54:40 -07:00

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: Austin Clements <austin@google.com>
This commit is contained in:
Dan Scales 2019-10-26 06:53:07 -07:00
parent 22d377077c
commit 1f3339f441
2 changed files with 10 additions and 5 deletions

View File

@ -371,7 +371,12 @@ func dumpgoroutine(gp *g) {
dumpint(uint64(d.sp))
dumpint(uint64(d.pc))
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))))
}
for p := gp._panic; p != nil; p = p.link {

View File

@ -824,10 +824,10 @@ type _defer struct {
// defers. We have only one defer record for the entire frame (which may
// currently have 0, 1, or more defers active).
openDefer bool
sp uintptr // sp at time of defer
pc uintptr // pc at time of defer
fn *funcval
_panic *_panic // panic that is running defer
sp uintptr // sp at time of defer
pc uintptr // pc at time of defer
fn *funcval // can be nil for open-coded defers
_panic *_panic // panic that is running defer
link *_defer
// If openDefer is true, the fields below record values about the stack