Repository: go
Issue: x/debug/cmd/viewcore: viewcore panic:Error while trying to run command "histo --top 10": runtime error: integer divide by zero
Labels: NeedsInvestigation

### Go version

go 1.19 amd64

### What operating system and processor architecture are you using (`go env`)?

```shell
GOARCH="amd64"
```


### What did you do?

I attempted to use viewcore on a core dump generate by gcore from pilot-discovery process. This process run in the pod, I want to analyze the heap situation of this process. Then i did
`./viewcore core.22 --exe /home/admin/pilot-gateway/bin/pilot-discovery`
`histo --top 10`

### What did you expect to see?

I want to see the top 10 objects with the highest memory usage

### What did you see instead?

but i see a error instead
first

```
Error while trying to run command "histo --top 10": address 5 is not mapped in the core file
Stack: goroutine 1 [running]:
runtime/debug.Stack()
	/opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/debug/stack.go:24 +0x65
main.capturePanic.func1()
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:372 +0x45
panic({0x7c7120, 0xc01220bc00})
	/opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/panic.go:884 +0x212
golang.org/x/debug/internal/core.(*Process).ReadUint64(0xc001cb8700?, 0x2300000000000030?)
	/Users/shuailiu/GolandProjects/debug/internal/core/read.go:81 +0x1b3
golang.org/x/debug/internal/core.(*Process).ReadUintptr(0x7cf3a0?, 0xc0139ab7f8?)
	/Users/shuailiu/GolandProjects/debug/internal/core/read.go:120 +0x36
golang.org/x/debug/internal/gocore.region.Uintptr({0xc001b60000?, 0xc0091b0390?, 0xc0000b60f0?})
	/Users/shuailiu/GolandProjects/debug/internal/gocore/region.go:40 +0x36
golang.org/x/debug/internal/gocore.(*Process).runtimeType2Type(0xc001b60000, 0x5, 0x8322b0?)
	/Users/shuailiu/GolandProjects/debug/internal/gocore/type.go:148 +0x1aa
golang.org/x/debug/internal/gocore.(*Process).typeObject(0xc001b60000, 0xc002de88c0, 0xc009f79130, {0x8dd850, 0xc001b56000}, 0xc013f073c0)
	/Users/shuailiu/GolandProjects/debug/internal/gocore/type.go:630 +0x9ae
golang.org/x/debug/internal/gocore.(*Process).typeObject(0xc001b60000, 0xc002de88c0, 0xc009f79090, {0x8dd850, 0xc001b56000}, 0xc013f073c0)
	/Users/shuailiu/GolandProjects/debug/internal/gocore/type.go:740 +0x6dc
golang.org/x/debug/internal/gocore.(*Process).typeHeap.func1()
	/Users/shuailiu/GolandProjects/debug/internal/gocore/type.go:523 +0x3ef
sync.(*Once).doSlow(0xc013f07688?, 0xc013f07690?)
	/opt/homebrew/Cellar/go/1.19.2/libexec/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
	/opt/homebrew/Cellar/go/1.19.2/libexec/src/sync/once.go:65
golang.org/x/debug/internal/gocore.(*Process).typeHeap(0x4119a4?)
	/Users/shuailiu/GolandProjects/debug/internal/gocore/type.go:377 +0x47
golang.org/x/debug/internal/gocore.(*Process).Type(0xc001b60000, 0xc007fae030?)
	/Users/shuailiu/GolandProjects/debug/internal/gocore/object.go:242 +0x25
main.typeName(0xc001b60000, 0xc000000000)
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:768 +0xac
main.runHistogram.func1(0xc000000000)
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:482 +0x46
golang.org/x/debug/internal/gocore.(*Process).ForEachObject(0xc001b60000, 0xc013f078c8)
	/Users/shuailiu/GolandProjects/debug/internal/gocore/object.go:202 +0xfa
main.runHistogram(0xb2d3c0?, {0xc019daa040?, 0x2?, 0x2?})
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:481 +0x1aa
github.com/spf13/cobra.(*Command).execute(0xb2d3c0, {0xc019daa020, 0x2, 0x2})
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:766 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0xc000004780)
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x2e5
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800
main.runRoot.func2()
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:361 +0x8a
main.capturePanic(0x8dbea0?)
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:376 +0x62
main.runRoot(0xb2c320, {0xc0000aa240?, 0x2?, 0x2?})
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:358 +0x6e5
github.com/spf13/cobra.(*Command).execute(0xb2c320, {0xc0000220a0, 0x2, 0x2})
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:766 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0xb2c320)
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x2e5
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800
main.main()
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:244 +0x12a`
```

and then rerun histo

```
Error while trying to run command "histo --top 10": runtime error: integer divide by zero
Stack: goroutine 1 [running]:
runtime/debug.Stack()
	/opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/debug/stack.go:24 +0x65
main.capturePanic.func1()
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:372 +0x45
panic({0x7d2d60, 0xb23b20})
	/opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/panic.go:884 +0x212
main.typeName(0xc0017ce000, 0xc00032c830)
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:773 +0x291
main.runHistogram.func1(0xc00032c830)
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:482 +0x46
golang.org/x/debug/internal/gocore.(*Process).ForEachObject(0xc0017ce000, 0xc011a638c8)
	/Users/shuailiu/GolandProjects/debug/internal/gocore/object.go:202 +0xfa
main.runHistogram(0xb2d3c0?, {0xc00e84f980?, 0x2?, 0x2?})
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:481 +0x1aa
github.com/spf13/cobra.(*Command).execute(0xb2d3c0, {0xc00e84f960, 0x2, 0x2})
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:766 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0xc000004780)
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x2e5
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800
main.runRoot.func2()
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:361 +0x8a
main.capturePanic(0x8dc3c0?)
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:376 +0x62
main.runRoot(0xb2c320, {0xc0000aa240?, 0x2?, 0x2?})
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:358 +0x6e5
github.com/spf13/cobra.(*Command).execute(0xb2c320, {0xc0000220a0, 0x2, 0x2})
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:766 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0xb2c320)
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x2e5
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/shuailiu/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800
main.main()
	/Users/shuailiu/GolandProjects/debug/cmd/viewcore/main.go:244 +0x12a
```