Closed
Description
I created an example repository to demonstrate the odd behaviour.
The file app/test/alive_testing.go is autogenerated. The code compiles and run:
$ go build
$ ./examplebug
$
Golangci cannot run megacheck:
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/msuppo/go/src/github.com/matteosuppo/examplebug /home/msuppo/go/src/github.com/matteosuppo /home/msuppo/go/src/github.com /home/msuppo/go/src /home/msuppo/go /home/msuppo /home /]
INFO [lintersdb] Active 9 linters: [deadcode errcheck gas govet ineffassign megacheck structcheck typecheck varcheck]
INFO [load/path_resolver] Skipped dirs: [vendor]
INFO [load/path_resolver] Paths resolving took 386.174µs: [. app app/test]
INFO [load] Program loading took 1.181177085s
INFO [load] SSA repr building took 580.090849ms
INFO [load] Not compiling packages: [github.com/matteosuppo/examplebug/app/test]
WARN [runner/megacheck] Can't run megacheck because of compilation errors in packages [github.com/matteosuppo/examplebug/app/test]: app/test/alive_testing.go:33: resp declared but not used and 1 more errors: run `golangci-lint run --no-config --disable-all -E typecheck` to see all errors
INFO [runner] worker.3 took 354.134µs with stages: varcheck: 100.664µs, megacheck: 71.052µs, errcheck: 58.018µs, deadcode: 48.715µs, structcheck: 27.192µs, typecheck: 9.285µs
INFO [runner] worker.1 took 511.825µs with stages: gas: 500.346µs
INFO [runner] worker.2 took 730.477µs with stages: ineffassign: 717.135µs
INFO [runner] worker.4 took 1.103226ms with stages: govet: 1.074584ms
INFO [runner] Workers idle times: #1: 557.34µs, #2: 330.556µs, #3: 745.415µs
INFO [runner] processing took 50.789µs with stages: autogenerated_exclude: 37.433µs, path_prettifier: 9.115µs, cgo: 978ns, max_same_issues: 849ns, max_from_linter: 437ns, exclude: 375ns, nolint: 368ns, max_per_file_from_linter: 367ns, diff: 314ns, skip_files: 293ns, uniq_by_line: 260ns
Congrats! No issues were found.
INFO [text_printer] Extracting issued lines took 0s
INFO Memory: 17 samples, avg is 259.4MB, max is 525.7MB
INFO Execution took 1.76946407s
Running typecheck doesn't find anything:
$ golangci-lint run --no-config --disable-all -E typecheck -v
INFO [lintersdb] Active 1 linters: [typecheck]
INFO [load/path_resolver] Skipped dirs: [vendor]
INFO [load/path_resolver] Paths resolving took 467.097µs: [. app app/test]
INFO [load] Program loading took 669.269302ms
INFO [load] Not compiling packages: [github.com/matteosuppo/examplebug/app/test]
INFO [runner] worker.4 took 6.969µs
INFO [runner] worker.2 took 6.356µs
INFO [runner] worker.1 took 6.692µs
INFO [runner] worker.3 took 65.306µs with stages: typecheck: 35.833µs
INFO [runner] Workers idle times: #1: 11.371µs, #2: 16.287µs, #4: 30.057µs
INFO [runner] processing took 54.491µs with stages: autogenerated_exclude: 37.912µs, path_prettifier: 12.67µs, cgo: 933ns, max_same_issues: 753ns, max_from_linter: 398ns, exclude: 365ns, nolint: 351ns, max_per_file_from_linter: 331ns, diff: 262ns, skip_files: 260ns, uniq_by_line: 256ns
Congrats! No issues were found.
INFO [text_printer] Extracting issued lines took 0s
INFO Memory: 7 samples, avg is 154.1MB, max is 251.5MB
INFO Execution took 677.481274ms
If I decide to skip that folder it panics:
$ golangci-lint run --skip-dirs=app -v
INFO [config_reader] Config search paths: [./ /home/msuppo/go/src/github.com/matteosuppo/examplebug /home/msuppo/go/src/github.com/matteosuppo /home/msuppo/go/src/github.com /home/msuppo/go/src /home/msuppo/go /home/msuppo /home /]
INFO [lintersdb] Active 9 linters: [deadcode errcheck gas govet ineffassign megacheck structcheck typecheck varcheck]
INFO [load/path_resolver] Skipped dirs: [app vendor]
INFO [load/path_resolver] Paths resolving took 216.74µs: [.]
INFO [load] pkg github.com/matteosuppo/examplebug files: [/home/msuppo/go/src/github.com/matteosuppo/examplebug/alive.go /home/msuppo/go/src/github.com/matteosuppo/examplebug/main.go]
INFO [load] Program loading took 1.487995352s
INFO [load] SSA repr building took 452.112419ms
INFO [runner] worker.4 took 2.219781ms with stages: govet: 1.393136ms, gas: 489.589µs, ineffassign: 169.916µs, errcheck: 43.061µs, deadcode: 37.417µs, varcheck: 33.12µs, structcheck: 14.196µs, typecheck: 1.449µs
INFO [runner] worker.2 took 7.387µs
INFO [runner] worker.3 took 3.354µs
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: recovered %!v(PANIC=runtime error: invalid memory address or nil pointer dereference)
[signal SIGSEGV: segmentation violation code=0xc420079678 addr=0x4cbb1d pc=0x888d62]
goroutine 859 [running]:
github.com/golangci/golangci-lint/vendor/honnef.co/go/tools/lint.(*fnVisitor).Visit.func1(0xc43d7e8c80)
/home/msuppo/go/src/github.com/golangci/golangci-lint/vendor/honnef.co/go/tools/lint/lint.go:836 +0xe0
panic(0xb38ec0, 0x115c7c0)
/usr/lib/go/src/runtime/panic.go:502 +0x229
github.com/golangci/golangci-lint/vendor/honnef.co/go/tools/lint.(*fnVisitor).Visit(0xc43d7e8c80, 0xd3cc20, 0xc4201b03c0, 0x0, 0x0)
/home/msuppo/go/src/github.com/golangci/golangci-lint/vendor/honnef.co/go/tools/lint/lint.go:842 +0xbe
github.com/golangci/golangci-lint/vendor/honnef.co/go/tools/lint.(*globalVisitor).Visit(0xc43d7e8c60, 0xd3cc20, 0xc4201b03c0, 0xd396e0, 0xc43d7e8c60)
/home/msuppo/go/src/github.com/golangci/golangci-lint/vendor/honnef.co/go/tools/lint/lint.go:820 +0xd1
go/ast.Walk(0xd396e0, 0xc43d7e8c60, 0xd3cc20, 0xc4201b03c0)
/usr/lib/go/src/go/ast/walk.go:52 +0x66
go/ast.walkDeclList(0xd396e0, 0xc43d7e8c60, 0xc4201b2240, 0x4, 0x4)
/usr/lib/go/src/go/ast/walk.go:38 +0x81
go/ast.Walk(0xd396e0, 0xc43d7e8c60, 0xd3cba0, 0xc4201c0100)
/usr/lib/go/src/go/ast/walk.go:353 +0x2650
github.com/golangci/golangci-lint/vendor/honnef.co/go/tools/lint.NodeFns.func1(0xc43dbf9d80, 0xc43d7e7560, 0xc429ef2d80)
/home/msuppo/go/src/github.com/golangci/golangci-lint/vendor/honnef.co/go/tools/lint/lint.go:787 +0x74
created by github.com/golangci/golangci-lint/vendor/honnef.co/go/tools/lint.NodeFns
/home/msuppo/go/src/github.com/golangci/golangci-lint/vendor/honnef.co/go/tools/lint/lint.go:784 +0xe7