Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/debug/cmd/viewcore: viewcore panic:Error while trying to run command "histo --top 10": runtime error: integer divide by zero #64442

Open
Erica177 opened this issue Nov 29, 2023 · 3 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Erica177
Copy link

Erica177 commented Nov 29, 2023

Go version

go 1.19 amd64

What operating system and processor architecture are you using (go env)?

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
@gopherbot gopherbot added this to the Unreleased milestone Nov 29, 2023
@dmitshur
Copy link
Contributor

Thanks for reporting. Does this also happen with Go 1.21 or 1.20? Go 1.19 is not supported.

CC @golang/runtime.

@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Nov 29, 2023
@prattmic
Copy link
Member

I'm not sure that viewcore works at all for recent versions of Go, but fixing it (and keeping it working) on our priority list (mainly tracked by #57447 (those are the packages that power viewcore)).

@Erica177
Copy link
Author

Erica177 commented Nov 30, 2023

Thanks for reporting. Does this also happen with Go 1.21 or 1.20? Go 1.19 is not supported.

CC @golang/runtime.

i tried Go1.21, and i found a new error

image

Then I checked the corresponding code and printed the relevant logs, and found that the error occurred in the "b := make([]byte, n)"

image

in my case, the log show that "n=9325427843449120385", It has exceeded the range of uint64, why does this situation occur

@seankhliao seankhliao removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants