goimportcycle
goimportcycle copied to clipboard
segmentation violation in `PrimitiveBuilder`
Hi,
parametalol@home:mygoproject$ go version
go version go1.22.7 linux/amd64
parametalol@home:mygoproject$ head go.mod
module github.com/mygoproject
go 1.22.5
parametalol@home:mygoproject$ goimportcycle -path . -dot imports.dot
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x4db9bf]
goroutine 9 [running]:
github.com/samlitowitz/goimportcycle/internal/ast.(*PrimitiveBuilder).addSelectorExpr(0x2?, 0xc000790f18)
/home/mipetrov/go/pkg/mod/github.com/samlitowitz/[email protected]/internal/ast/primitive_builder.go:375 +0x29f
github.com/samlitowitz/goimportcycle/internal/ast.(*PrimitiveBuilder).AddNode(0xc000186fb0?, {0x54e3e8?, 0xc000790f18?})
/home/mipetrov/go/pkg/mod/github.com/samlitowitz/[email protected]/internal/ast/primitive_builder.go:113 +0x6e
main.detectInputCycles.func1()
/home/mipetrov/go/pkg/mod/github.com/samlitowitz/[email protected]/cmd/goimportcycle/main.go:109 +0xc6
created by main.detectInputCycles in goroutine 1
/home/mipetrov/go/pkg/mod/github.com/samlitowitz/[email protected]/cmd/goimportcycle/main.go:101 +0xaf
Same thing here, with go version go1.24.1 darwin/arm64
$ goimportcycle
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x104e5d458]
goroutine 9 [running]:
github.com/samlitowitz/goimportcycle/internal/ast.(*PrimitiveBuilder).addSelectorExpr(0x2?, 0x1400029b710)
/Users/abourget/go/pkg/mod/github.com/samlitowitz/[email protected]/internal/ast/primitive_builder.go:375 +0x208
github.com/samlitowitz/goimportcycle/internal/ast.(*PrimitiveBuilder).AddNode(0x14000107fa8?, {0x104ede5e8?, 0x1400029b710?})
/Users/abourget/go/pkg/mod/github.com/samlitowitz/[email protected]/internal/ast/primitive_builder.go:113 +0x78
main.detectInputCycles.func1()
/Users/abourget/go/pkg/mod/github.com/samlitowitz/[email protected]/cmd/goimportcycle/main.go:109 +0xa0
created by main.detectInputCycles in goroutine 1
/Users/abourget/go/pkg/mod/github.com/samlitowitz/[email protected]/cmd/goimportcycle/main.go:101 +0xac
@abourget would you please retry this with the latest version, v1.0.9 at the time of writing this, and provide an example GitHub repository which you are able to replicate this issue on.