golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.3k stars 610 forks source link

Nil pointer dereference error, v1.3.1 #307

Closed lucbarr closed 4 years ago

lucbarr commented 5 years ago

Ran installation as in README.md and for every file I run mockgen I get:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x63db27]

goroutine 1 [running]:
golang.org/x/tools/go/packages.runContainsQueries(0xc420116008, 0x701be8, 0xc4200479e0, 0xc420112040, 0x1, 0x1, 0x0, 0x1)
        /home/luciano/go/src/golang.org/x/tools/go/packages/golist.go:240 +0x697
golang.org/x/tools/go/packages.goListDriver(0xc420116008, 0xc420112000, 0x1, 0x1, 0xc420116000, 0xc420116030, 0xc420116060)
        /home/luciano/go/src/golang.org/x/tools/go/packages/golist.go:150 +0x15cc
golang.org/x/tools/go/packages.defaultDriver(0xc420116008, 0xc420112000, 0x1, 0x1, 0x0, 0xc420047ad8, 0x441c27)
        /home/luciano/go/src/golang.org/x/tools/go/packages/packages.go:220 +0x68
golang.org/x/tools/go/packages.Load(0xc420047d08, 0xc420112000, 0x1, 0x1, 0x62, 0xc420114000, 0x67, 0x6bfee0, 0x7f5679875401)
        /home/luciano/go/src/golang.org/x/tools/go/packages/packages.go:205 +0x6f
main.parseFile(0x7fffba647088, 0x62, 0xc420047ed0, 0x6f0e92, 0x7)
        /home/luciano/go/src/github.com/golang/mock/mockgen/parse.go:51 +0x20b
main.main()
        /home/luciano/go/src/github.com/golang/mock/mockgen/mockgen.go:65 +0x9eb

Tried manually compiling mockgen, got the same error. After recompiling for v1.2.0 - last version I record working properly - , everything works fine. It might be somewhat related to this https://github.com/golang/mock/blob/master/mockgen/parse.go#L51

any clue, anyone?

poy commented 5 years ago

Can you please show the command you ran that lead to the panic?

lucbarr commented 5 years ago

Can you please show the command you ran that lead to the panic?

mockgen -source=<path-to-file>

codyoss commented 4 years ago

Hey @lucbarr thanks for the report. Can you provide a small file that is able to reproduce this?

lucbarr commented 4 years ago

I don't have the files anymore, and the error didn't happen again. I'm closing this, thanks for the willingness, fellows.