commit | 7c4558292c671977645c344ac3b5760cfe11147d | [log] [tgz] |
---|---|---|
author | Nicolas Hillegeer <aktau@google.com> | Sat Oct 12 14:59:46 2024 -0700 |
committer | Gopher Robot <gobot@golang.org> | Mon Oct 14 01:08:16 2024 +0000 |
tree | f8fba1479dec5953f1dd61517e57b3c355201d7e | |
parent | dfd7e92aa331f2d584bfefaab2d0432a1bb8c91d [diff] |
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Nicolas Hillegeer <aktau@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This repository holds utilities and libraries for debugging Go programs.
WARNING! Please expect breaking changes and unstable APIs. Most of them are currently are at an early, experimental stage.
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.
The main issue tracker for the debug repository is located at https://github.com/golang/go/issues. Prefix your issue with “x/debug:” in the subject line, so it is easy to find.