From 535741a69a1300d1fe2800778b99c8a1b75d7fdd Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 8 Jan 2016 16:25:29 -0500 Subject: debug/dwarf: fix nil pointer dereference in cyclic type structures Currently readType simultaneously constructs a type graph and resolves the sizes of the types. However, these two operations are fundamentally at odds: the order we parse a cyclic structure in may be different than the order we need to resolve type sizes in. As a result, it's possible that when readType attempts to resolve the size of a typedef, it may dereference a nil Type field of another typedef retrieved from the type cache that's only partially constructed. To fix this, we delay resolving typedef sizes until the end of the readType recursion, when the full type graph is constructed. Fixes #13039. Change-Id: I9889af37fb3be5437995030fdd61e45871319d07 Reviewed-on: https://go-review.googlesource.com/18459 Reviewed-by: Russ Cox Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot --- src/debug/dwarf/typeunit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/debug/dwarf/typeunit.go') diff --git a/src/debug/dwarf/typeunit.go b/src/debug/dwarf/typeunit.go index 9cfb4a8b25..0f4e07ebf7 100644 --- a/src/debug/dwarf/typeunit.go +++ b/src/debug/dwarf/typeunit.go @@ -101,7 +101,7 @@ func (d *Data) sigToType(sig uint64) (Type, error) { b := makeBuf(d, tu, tu.name, tu.off, tu.data) r := &typeUnitReader{d: d, tu: tu, b: b} - t, err := d.readType(tu.name, r, Offset(tu.toff), make(map[Offset]Type)) + t, err := d.readType(tu.name, r, Offset(tu.toff), make(map[Offset]Type), nil) if err != nil { return nil, err } -- cgit v1.3-5-g9baa