Skip to content
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

Panic on dependency compilation error #156

Closed
matteosuppo opened this issue Jul 10, 2018 · 3 comments
Closed

Panic on dependency compilation error #156

matteosuppo opened this issue Jul 10, 2018 · 3 comments
Labels
bug Something isn't working

Comments

@matteosuppo
Copy link

examplebug.zip

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
@jirfag
Copy link
Member

jirfag commented Jul 25, 2018

we should have stop linting with warning about

/Users/denis/go/src/github.com/matteosuppo/examplebug/app/test/alive_testing.go:33:3: resp declared but not used
/Users/denis/go/src/github.com/matteosuppo/examplebug/app/test/alive_testing.go:96:3: resp declared but not used

But we didn't do it because of some bug. As a workaround you can fix this compilation issue.

@jirfag jirfag added the bug Something isn't working label Jul 25, 2018
@jirfag
Copy link
Member

jirfag commented Jul 28, 2018

Got it. Golangci-lint didn't report concrete compilation errors because they are in generated files.
I made a fix to not panic but write about compilation errors:

~/go/src/github.com/matteosuppo/examplebug$ golangci-lint run
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
C

@jirfag jirfag changed the title Generated file is skipped but causes megacheck to fail Panic on system dependency compilation error Jul 28, 2018
@jirfag jirfag changed the title Panic on system dependency compilation error Panic on dependency compilation error Jul 28, 2018
@jirfag
Copy link
Member

jirfag commented Jul 28, 2018

closing, reopen if it doesn't help

@jirfag jirfag closed this as completed Jul 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants