ondrajz / go-callvis

Visualize call graph of a Go program using Graphviz
https://ofabry.github.io/go-callvis
MIT License
6k stars 424 forks source link

panic: T for Rta algo #161

Open Gaojianli opened 1 year ago

Gaojianli commented 1 year ago

Hello, i am using go-callvis with the rta algorithm. However i got a panic with it:

$ go-callvis  -algo rta .
panic: T

goroutine 1 [running]:
golang.org/x/tools/go/callgraph/rta.(*rta).addRuntimeType(0x1429b671b58, {0x105580d88?, 0x1404e342e10?}, 0x0)
        golang.org/x/tools@v0.8.0/go/callgraph/rta/rta.go:457 +0x7a0
golang.org/x/tools/go/callgraph/rta.(*rta).addRuntimeType(0x1429b671b58, {0x105580ce8?, 0x1404e36dfa0?}, 0x1)
        golang.org/x/tools@v0.8.0/go/callgraph/rta/rta.go:416 +0x568
golang.org/x/tools/go/callgraph/rta.(*rta).addRuntimeType(0x1429b671b58, {0x105580c70?, 0x1404e176690?}, 0x0)
        golang.org/x/tools@v0.8.0/go/callgraph/rta/rta.go:441 +0x6a4
golang.org/x/tools/go/callgraph/rta.(*rta).visitFunc(0x0?, 0x141a0323200)
        golang.org/x/tools@v0.8.0/go/callgraph/rta/rta.go:248 +0x14c
golang.org/x/tools/go/callgraph/rta.Analyze({0x1428d8bfad8, 0x1, 0x10538ce8a?}, 0x1)
        golang.org/x/tools@v0.8.0/go/callgraph/rta/rta.go:300 +0x3d0
main.(*analysis).DoAnalysis(0x14000020b40, {0x16b003749, 0x3}, {0x0?, 0x14000056708?}, 0xe8?, {0x140000200b0?, 0x300000002?, 0x140000b9f28?})
        github.com/ofabry/go-callvis/analysis.go:118 +0x710
main.main()
        github.com/ofabry/go-callvis/main.go:145 +0x294

it seems that the panic occurs on following code:

type Iter[T any] interface {
    // Next returns next N items of iterator when it is not empty.
    // When iterator is empty, nil is returned.
    // When n = [ALL] or n is greater than number of remaining elements,
    // all remaining are returned.
    //
    // The returned slice is owned by caller. So implementer should return a
    // newly allocated slice if needed.
    //
    // Passing in a negative n (except [ALL]) is undefined behavior.
    Next(n int) []T
}

Does the RTA algorithm not support generics?

cnzhujie commented 2 weeks ago

https://github.com/golang/go/issues/60137

The issue is due to I didn't used the mode ssa.InstantiateGenerics when building ssa packages.