Skip to content

x/tools/callgraph: panic: Cannot range over: func(yield func(E) bool) #71930

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

Closed
FlorianO opened this issue Feb 24, 2025 · 3 comments
Closed

x/tools/callgraph: panic: Cannot range over: func(yield func(E) bool) #71930

FlorianO opened this issue Feb 24, 2025 · 3 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@FlorianO
Copy link

Go version

go version go1.24.0 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/$USER/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/$USER/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/30/fz7ryvm518v086x8wqbq_pfw0000gn/T/go-build3461295816=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOOS='darwin'
GOPATH='/Users/$USER/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.24.0/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/$USER/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.24.0/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Added callgraph to go.mod like this:
tool golang.org/x/tools/cmd/callgraph

then call it with:
go tool callgraph -format digraph cmd/$PROJECT/main.go

What did you see happen?

`panic: Cannot range over: func(yield func(string) bool)

goroutine 3375 [running]:
golang.org/x/tools/go/ssa.(*builder).rangeStmt(0x14017fce080, 0x14018073380, 0x14003046180, 0x0)
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:2278 +0x850
golang.org/x/tools/go/ssa.(*builder).stmt(0x14017fce080, 0x14018073380, {0x100f7bdf8?, 0x14003046180?})
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:2508 +0x138
golang.org/x/tools/go/ssa.(*builder).stmtList(...)
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:908
golang.org/x/tools/go/ssa.(*builder).stmt(0x14017fce080, 0x14018073380, {0x100f7bac8?, 0x1400332f230?})
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:2470 +0x13b8
golang.org/x/tools/go/ssa.(*builder).buildFromSyntax(0x14017fce080, 0x14018073380)
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:2582 +0x208
golang.org/x/tools/go/ssa.(*builder).buildFunction(0x1?, 0x14018073380)
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:2536 +0x10c
golang.org/x/tools/go/ssa.(*builder).iterate(0x14017fce080)
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:2524 +0x2c
golang.org/x/tools/go/ssa.(*Package).build(0x1401571ad80)
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:2658 +0xa4
sync.(*Once).doSlow(0x59?, 0x140103483b0?)
/opt/homebrew/Cellar/go/1.24.0/libexec/src/sync/once.go:78 +0xf0
sync.(*Once).Do(...)
/opt/homebrew/Cellar/go/1.24.0/libexec/src/sync/once.go:69
golang.org/x/tools/go/ssa.(*Package).Build(...)
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:2647
golang.org/x/tools/go/ssa.(*Program).Build.func1(0x0?)
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:2626 +0x50
created by golang.org/x/tools/go/ssa.(*Program).Build in goroutine 1
/Users/$USER/go/pkg/mod/golang.org/x/tools@v0.20.0/go/ssa/builder.go:2625 +0x178`

What did you expect to see?

A nice digraph

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Feb 24, 2025
@gopherbot gopherbot added this to the Unreleased milestone Feb 24, 2025
@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Feb 24, 2025
@seankhliao
Copy link
Member

upgrade x/tools, v0.20.0 is too old.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2025
@FlorianO
Copy link
Author

If someone stumbles apon this and you have configured the tool through go.mod:
go get golang.org/x/tools@v0.30.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants