Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/gocore: fix large types dereference (Go 1.22+)
viewcore supports Go 1.22+ allocation headers since CL 608475. The CL description mentions: > This gets the goroot test passing again, which is a low bar... but > it's something. This CL fixes an untested path, and modifies test.go to hit that path by allocating a "large" object (>32760 bytes). When allocating a large object, viewcore panics: ``` panic: asking for field of non-struct [recovered] panic: asking for field of non-struct goroutine 170 [running]: testing.tRunner.func1.2({0x72ce80, 0x7b86c0}) /usr/lib/google-golang/src/testing/testing.go:1632 +0x230 testing.tRunner.func1() /usr/lib/google-golang/src/testing/testing.go:1635 +0x35e panic({0x72ce80?, 0x7b86c0?}) /usr/lib/google-golang/src/runtime/panic.go:785 +0x132 golang.org/x/debug/internal/gocore.(*Type).field(...) /usr/local/google/home/aktau/gob/go/debug/internal/gocore/type.go:85 golang.org/x/debug/internal/gocore.region.Field(...) /usr/local/google/home/aktau/gob/go/debug/internal/gocore/region.go:163 golang.org/x/debug/internal/gocore.(*Process).readSpans(0xc0001fe000, {0xc0001fe000?, 0xc000000f50?, 0xc000000500?}, {0xc000aa0480?, 0x1, 0xc0005d7260?}) /usr/local/google/home/aktau/gob/go/debug/internal/gocore/process.go:596 +0x5125 golang.org/x/debug/internal/gocore.(*Process).readHeap(0xc0001fe000) /usr/local/google/home/aktau/gob/go/debug/internal/gocore/process.go:254 +0x569 golang.org/x/debug/internal/gocore.Core(0xc0001f4000) ``` Indeed, `largeType` is not a struct, but a pointer to a struct: ``` // src/runtime/mheap.go type mspan struct { _ sys.NotInHeap // ... largeType *_type // malloc header for large objects. } ``` Add a `Deref()` operation to fix this. Afterwards, the test does not panic anymore. Though no attempt has been made to verify that the results are good. Change-Id: I3569e5e1fba14a311507944f75e2ee2d27616a15 Reviewed-on: https://go-review.googlesource.com/c/debug/+/619875 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Nicolas Hillegeer <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
- Loading branch information