Skip to content

megacheck panic in go1.11 with interface conversion: types.Object is nil, not *types.Func: #418

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

Closed
wgjak47 opened this issue Mar 6, 2019 · 9 comments

Comments

@wgjak47
Copy link

wgjak47 commented Mar 6, 2019

Thank you for creating the issue!

Please include the following information:

  1. Version of golangci-lint: golangci-lint --version (or git commit if you don't use binary distribution)
    golangci-lint has version v1.15.0-7-g7514bf8 built from 7514bf8
  2. Config file: cat .golangci.yml
    no .golangci.yml
  3. Go environment: go version && go env
go version go1.11.5 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/wgjak47/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/wgjak47/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="x86_64-pc-linux-gnu-gcc"
CXX="x86_64-pc-linux-gnu-g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build704478493=/tmp/go-build -gno-record-gcc-switches"
  1. Verbose output of running: golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/wgjak47/go/src/monitor2-go /home/wgjak47/go/src /home/wgjak47/go /home/wgjak47 /home /] 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [lintersdb] Optimized sublinters [staticcheck gosimple unused] into metalinter megacheck 
INFO [loader] Go packages loading at mode load deps types and syntax took 1.540141747s 
INFO [loader] SSA repr building timing: packages building 25.146051ms, total 251.06431ms 
INFO [loader] Packages that do not compile: [monitor2-go/test] 
INFO [runner] worker.7 took 165.229µs with stages: typecheck: 141.319µs 
INFO [runner] worker.5 took 4.746336ms with stages: errcheck: 4.740566ms 
INFO [runner] worker.1 took 6.708146ms with stages: structcheck: 6.704646ms 
INFO [runner] worker.6 took 8.814065ms with stages: deadcode: 8.810575ms 
INFO [runner] worker.8 took 16.806814ms with stages: varcheck: 16.800434ms 
INFO [runner] worker.2 took 38.862261ms with stages: govet: 38.855051ms 
INFO [runner] worker.3 took 45.496966ms with stages: ineffassign: 45.491146ms 
WARN [runner] Panic stack trace: goroutine 4106 [running]:
runtime/debug.Stack(0xe2e89e, 0x12, 0xc048d90900)
        /usr/lib/go/src/runtime/debug/stack.go:24 +0xa7
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runLinterSafe.func1(0xc048d91d38, 0xc048d91f08)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:99 +0xb7
panic(0xcae240, 0xc02601c400)
        /usr/lib/go/src/runtime/panic.go:513 +0x1b9
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint(0xc048d916a8, 0xc01b983400, 0x44, 0x80, 0xc048d91670, 0x0, 0x0, 0xc028ce2240)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:477 +0x34c2
github.com/golangci/golangci-lint/pkg/golinters.runMegacheckCheckers(0xc028ce40c0, 0x3, 0x4, 0xc0000808c0, 0xc01b983400, 0x44, 0x80, 0x4, 0xf368a0, 0xc004466750, ...)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/golinters/megacheck.go:349 +0x1f3
github.com/golangci/golangci-lint/pkg/golinters.megacheck.runMegacheck(0x10101, 0xc01b983400, 0x44, 0x80, 0x203000, 0x20300a, 0xc000080a50, 0x40db0f, 0xc028ce21c0, 0x20)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/golinters/megacheck.go:303 +0x182
github.com/golangci/golangci-lint/pkg/golinters.megacheck.Run(0xc000010101, 0xf3c5c0, 0xc0000cd200, 0xc029300000, 0xc02921eb80, 0xdd4653, 0x9, 0xf43800, 0xc0286719b0)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/golinters/megacheck.go:243 +0x111
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runLinterSafe(0xc000080f08, 0xf3c5c0, 0xc0000cd200, 0xc0291f6070, 0xc000159600, 0x0, 0x0, 0x0, 0xf31c40, 0xc02fc71330)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:105 +0x161
github.com/golangci/golangci-lint/pkg/lint.Runner.runWorker.func1()
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:139 +0x64
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc013192190, 0xdd4653, 0x9, 0xc0012b3668)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:75 +0x50
github.com/golangci/golangci-lint/pkg/lint.Runner.runWorker(0xc0292b8000, 0x11, 0x11, 0xf43800, 0xc029242660, 0xf3c5c0, 0xc0000cd200, 0xc0291f6070, 0xc029266a20, 0xc029266a80, ...)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:138 +0x19c
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runWorkers.func1(0xc0292937e0, 0xc0292ba000, 0xf3c5c0, 0xc0000cd200, 0xc0291f6070, 0xc029266a20, 0xc029266a80, 0xc026103440, 0x8, 0x8, ...)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:193 +0x13b
created by github.com/golangci/golangci-lint/pkg/lint.(*Runner).runWorkers
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:190 +0x1b5
 
INFO [runner] worker.4 took 1.586295533s with stages: megacheck: 1.586288103s 
INFO [runner] Workers idle times: #1: 1.579556428s, #2: 1.547418943s, #3: 1.540785497s, #5: 1.581516597s, #6: 1.577437238s, #7: 1.585975915s, #8: 1.569454169s 
WARN [runner] Can't run linter megacheck: panic occurred: panic: interface conversion: types.Object is nil, not *types.Func: goroutine 4921 [running]:
runtime/debug.Stack(0xc0451c58a8, 0xcc44c0, 0xc02da777a0)
        /usr/lib/go/src/runtime/debug/stack.go:24 +0xa7
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint.func1.1(0xc022839b90)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:458 +0x60
panic(0xcc44c0, 0xc02da777a0)
        /usr/lib/go/src/runtime/panic.go:513 +0x1b9
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated.func1(0xf35f20, 0xc00f963a10, 0xf36601)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck/lint.go:2407 +0x62d
go/ast.inspector.Visit(0xc030ebe780, 0xf35f20, 0xc00f963a10, 0xf33620, 0xc030ebe780)
        /usr/lib/go/src/go/ast/walk.go:373 +0x3a
go/ast.Walk(0xf33620, 0xc030ebe780, 0xf35f20, 0xc00f963a10)
        /usr/lib/go/src/go/ast/walk.go:52 +0x66
go/ast.walkDeclList(0xf33620, 0xc030ebe780, 0xc00779ac80, 0x5, 0x8)
        /usr/lib/go/src/go/ast/walk.go:38 +0x9e
go/ast.Walk(0xf33620, 0xc030ebe780, 0xf35ea0, 0xc00779ad00)
        /usr/lib/go/src/go/ast/walk.go:353 +0x2656
go/ast.Inspect(0xf35ea0, 0xc00779ad00, 0xc030ebe780)
        /usr/lib/go/src/go/ast/walk.go:385 +0x4b
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated(0xc028ce2200, 0xc022839b90)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck/lint.go:2448 +0xe6
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated-fm(0xc022839b90)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck/lint.go:242 +0x34
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint.func1(0xc02c9d09c0, 0xc02ea3a9c0, 0xc022839b90)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:469 +0x102
created by github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:455 +0x1d81
 
INFO [runner/max_same_issues] 7/10 issues with text "Error return value of `(*monitor2-go/vendor/github.com/go-xorm/xorm.Session).Find` is not checked" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "Error return value of `io.WriteString` is not checked" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "unreachable code" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "Error return value of `entityMeasureMap.SetP` is not checked" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "ineffectual assignment to `ok`" were hidden, use --max-same-issues 
INFO [runner/max_from_linter] 1/51 issues from linter errcheck were hidden, use --max-issues-per-linter 
INFO [runner] Issues before processing: 174, after processing: 106 
INFO [runner] processing took 15.478069ms with stages: exclude: 6.507746ms, identifier_marker: 3.697111ms, skip_dirs: 1.947741ms, autogenerated_exclude: 1.078323ms, source_code: 832.405µs, cgo: 562.659µs, nolint: 358.209µs, path_prettifier: 162.857µs, max_same_issues: 115.718µs, uniq_by_line: 82.07µs, max_from_linter: 37.41µs, path_shortener: 34.18µs, max_per_file_from_linter: 30.79µs, replacement_builder: 26.92µs, diff: 1.7µs, skip_files: 1.12µs, exclude-rules: 1.11µs 
INFO Memory: 34 samples, avg is 719.8MB, max is 1353.4MB 
INFO Execution took 3.411303136s    
@wgjak47
Copy link
Author

wgjak47 commented Mar 6, 2019

I tried #411 to solve my problem...it not work...

jirfag added a commit that referenced this issue Mar 18, 2019
@jirfag
Copy link
Contributor

jirfag commented Mar 18, 2019

hi, thank you for reporting!
how can I reproduce it?

jirfag added a commit that referenced this issue Mar 18, 2019
@wgjak47
Copy link
Author

wgjak47 commented Mar 18, 2019

I update golangci-linter using go get -u github.com/golangci/golangci-lint/cmd/golangci-lint and update golang to 1.12, seems another problem happend:

INFO [config_reader] Config search paths: [./ /home/wgjak47/go/src/monitor2-go /home/wgjak47/go/src /home/wgjak47/go /home/wgjak47 /home /] 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [lintersdb] Optimized sublinters [staticcheck gosimple unused] into metalinter megacheck 
INFO [loader] Go packages loading at mode load deps types and syntax took 1.566451362s 
INFO [loader] SSA repr building timing: packages building 24.464631ms, total 248.794988ms 
INFO [loader] Packages that do not compile: [monitor2-go/modules/tag_hot_processor monitor2-go/test] 
INFO [runner] worker.7 took 91.079µs with stages: typecheck: 87.439µs 
WARN [runner/govet] govet error: asmdecl: analysis skipped due to errors in package 
WARN [runner/govet] govet error: assign: analysis skipped due to errors in package 
WARN [runner/govet] govet error: assign: analysis skipped due to errors in package 
WARN [runner/govet] govet error: atomicalign: analysis skipped due to errors in package 
WARN [runner/govet] govet error: atomicalign: analysis skipped due to errors in package 
WARN [runner/govet] govet error: bools: analysis skipped due to errors in package 
WARN [runner/govet] govet error: bools: analysis skipped due to errors in package 
WARN [runner/govet] govet error: buildtag: analysis skipped due to errors in package 
WARN [runner/govet] govet error: buildtag: analysis skipped due to errors in package 
WARN [runner/govet] govet error: httpresponse: analysis skipped due to errors in package 
WARN [runner/govet] govet error: httpresponse: analysis skipped due to errors in package 
WARN [runner/govet] govet error: loopclosure: analysis skipped due to errors in package 
WARN [runner/govet] govet error: loopclosure: analysis skipped due to errors in package 
WARN [runner/govet] govet error: ctrlflow: analysis skipped due to errors in package 
WARN [runner/govet] govet error: lostcancel: failed prerequisites: ctrlflow@monitor2-go/modules/tag_hot_processor 
WARN [runner/govet] govet error: ctrlflow: analysis skipped due to errors in package 
WARN [runner/govet] govet error: lostcancel: failed prerequisites: ctrlflow@monitor2-go/test 
WARN [runner/govet] govet error: nilfunc: analysis skipped due to errors in package 
WARN [runner/govet] govet error: nilfunc: analysis skipped due to errors in package 
WARN [runner/govet] govet error: printf: analysis skipped due to errors in package 
WARN [runner/govet] govet error: printf: analysis skipped due to errors in package 
WARN [runner/govet] govet error: shift: analysis skipped due to errors in package 
WARN [runner/govet] govet error: shift: analysis skipped due to errors in package 
WARN [runner/govet] govet error: stdmethods: analysis skipped due to errors in package 
WARN [runner/govet] govet error: stdmethods: analysis skipped due to errors in package 
WARN [runner/govet] govet error: tests: analysis skipped due to errors in package 
WARN [runner/govet] govet error: tests: analysis skipped due to errors in package 
WARN [runner/govet] govet error: unmarshal: analysis skipped due to errors in package 
WARN [runner/govet] govet error: unmarshal: analysis skipped due to errors in package 
WARN [runner/govet] govet error: unsafeptr: analysis skipped due to errors in package 
WARN [runner/govet] govet error: unsafeptr: analysis skipped due to errors in package 
WARN [runner/govet] govet error: unusedresult: analysis skipped due to errors in package 
WARN [runner/govet] govet error: unusedresult: analysis skipped due to errors in package 
WARN [runner/govet] govet error: buildssa: analysis skipped due to errors in package 
WARN [runner/govet] govet error: nilness: failed prerequisites: buildssa@monitor2-go/modules/tag_hot_processor 
WARN [runner/govet] govet error: buildssa: analysis skipped due to errors in package 
WARN [runner/govet] govet error: nilness: failed prerequisites: buildssa@monitor2-go/test 
INFO [runner] worker.6 took 621.636306ms with stages: govet: 621.630176ms 
WARN [runner] Can't run linter govet: asmdecl: analysis skipped due to errors in package 
WARN [runner] Panic stack trace: goroutine 4546 [running]:
runtime/debug.Stack(0xd234c0, 0xc05fbfa7a0, 0xc000fc28f8)
        /usr/lib/go/src/runtime/debug/stack.go:24 +0x9d
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runLinterSafe.func1(0xc000fc3ce8, 0xc000fc3ee0)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:106 +0xfd
panic(0xcfa1c0, 0xc081f7e010)
        /usr/lib/go/src/runtime/panic.go:522 +0x1b5
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint(0xc000fc3658, 0xc01b989000, 0x44, 0x80, 0xc000fc3620, 0x0, 0x0, 0xc029eecba0)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:477 +0x343c
github.com/golangci/golangci-lint/pkg/golinters.runMegacheckCheckers(0xc029ef8040, 0x3, 0x4, 0xc001151870, 0xc01b989000, 0x44, 0x80, 0x4, 0x1, 0xc0011517c0, ...)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/golinters/megacheck.go:349 +0x1f3
github.com/golangci/golangci-lint/pkg/golinters.megacheck.runMegacheck(0xc000010101, 0xc01b989000, 0x44, 0x80, 0x0, 0xc0011519f8, 0x40d919, 0xc029ec5770, 0x30, 0x30)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/golinters/megacheck.go:303 +0x182
github.com/golangci/golangci-lint/pkg/golinters.megacheck.Run(0x10101, 0xfe2e20, 0xc00009aae0, 0xc029e81dc0, 0xc02a3f7c10, 0x1, 0x1, 0xfe9cc0, 0xc02a424b20)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/golinters/megacheck.go:243 +0xe8
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runLinterSafe(0xc001151ee0, 0xfe2e20, 0xc00009aae0, 0xc02a466000, 0xc00034f880, 0x0, 0x0, 0x0, 0xfcc580, 0xc05fbfa7a0)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:112 +0x16a
github.com/golangci/golangci-lint/pkg/lint.Runner.runWorker.func1()
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:146 +0x64
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc029ee4370, 0xe250c6, 0x9, 0xc000bd4e40)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:75 +0x50
github.com/golangci/golangci-lint/pkg/lint.Runner.runWorker(0xc0293786c0, 0x11, 0x11, 0xfecde0, 0xc02a3f3cb0, 0xfe2e20, 0xc00009aae0, 0xc02a466000, 0xc02a2bafc0, 0xc02a2bb020, ...)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:145 +0x23b
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runWorkers.func1(0xc02a4be530, 0xc02a46d620, 0xfe2e20, 0xc00009aae0, 0xc02a466000, 0xc02a2bafc0, 0xc02a2bb020, 0xc02a47a0c0, 0x8, 0x8, ...)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:200 +0x163
created by github.com/golangci/golangci-lint/pkg/lint.(*Runner).runWorkers
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:197 +0x1ab
 
INFO [runner] worker.2 took 1.988622811s with stages: megacheck: 1.988616191s 
INFO [runner] Workers idle times: #1: 1.968378845s, #3: 1.973861545s, #4: 1.982433114s, #5: 1.97243179s, #6: 1.366969325s, #7: 1.988481552s, #8: 1.670496954s 
WARN [runner] Can't run linter megacheck: panic occurred: panic: runtime error: invalid memory address or nil pointer dereference: goroutine 12872 [running]:
runtime/debug.Stack(0xc0832a2bb0, 0xd0a720, 0x16df9a0)
        /usr/lib/go/src/runtime/debug/stack.go:24 +0x9d
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint.func1.1(0xc08311a000)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:458 +0x60
panic(0xd0a720, 0x16df9a0)
        /usr/lib/go/src/runtime/panic.go:522 +0x1b5
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/simple.(*Checker).LintMakeLenCap.func1(0xfd7180, 0xc01f1d04c0, 0xfd7001)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/simple/lint.go:1365 +0x580
go/ast.inspector.Visit(0xc0835f1760, 0xfd7180, 0xc01f1d04c0, 0xfcdec0, 0xc0835f1760)
        /usr/lib/go/src/go/ast/walk.go:373 +0x3a
go/ast.Walk(0xfcdec0, 0xc0835f1760, 0xfd7180, 0xc01f1d04c0)
        /usr/lib/go/src/go/ast/walk.go:52 +0x66
go/ast.walkExprList(0xfcdec0, 0xc0835f1760, 0xc01ef77580, 0x1, 0x1)
        /usr/lib/go/src/go/ast/walk.go:26 +0x9e
go/ast.Walk(0xfcdec0, 0xc0835f1760, 0xfd6f80, 0xc01f1d0500)
        /usr/lib/go/src/go/ast/walk.go:207 +0x2103
go/ast.walkStmtList(0xfcdec0, 0xc0835f1760, 0xc00ba75be0, 0x2, 0x2)
        /usr/lib/go/src/go/ast/walk.go:32 +0x9e
go/ast.Walk(0xfcdec0, 0xc0835f1760, 0xfd7100, 0xc01f181500)
        /usr/lib/go/src/go/ast/walk.go:224 +0x1b67
go/ast.Walk(0xfcdec0, 0xc0835f1760, 0xfd75c0, 0xc01ef775b0)
        /usr/lib/go/src/go/ast/walk.go:98 +0x2c13
go/ast.Walk(0xfcdec0, 0xc0835f1760, 0xfd7840, 0xc01f181530)
        /usr/lib/go/src/go/ast/walk.go:151 +0x3a8
go/ast.walkExprList(0xfcdec0, 0xc0835f1760, 0xc01ef775c0, 0x1, 0x1)
        /usr/lib/go/src/go/ast/walk.go:26 +0x9e
go/ast.Walk(0xfcdec0, 0xc0835f1760, 0xfd7300, 0xc01f1d0540)
        /usr/lib/go/src/go/ast/walk.go:104 +0x431
go/ast.walkExprList(0xfcdec0, 0xc0835f1760, 0xc01ef775d0, 0x1, 0x1)
        /usr/lib/go/src/go/ast/walk.go:26 +0x9e
go/ast.Walk(0xfcdec0, 0xc0835f1760, 0xfd7cc0, 0xc01f2085a0)
        /usr/lib/go/src/go/ast/walk.go:308 +0x570
go/ast.Walk(0xfcdec0, 0xc0835f1760, 0xfd7640, 0xc01f1d0680)
        /usr/lib/go/src/go/ast/walk.go:331 +0xf4a
go/ast.walkDeclList(0xfcdec0, 0xc0835f1760, 0xc01f38a200, 0x14, 0x20)
        /usr/lib/go/src/go/ast/walk.go:38 +0x9e
go/ast.Walk(0xfcdec0, 0xc0835f1760, 0xfd7500, 0xc01f248c80)
        /usr/lib/go/src/go/ast/walk.go:353 +0x2659
go/ast.Inspect(...)
        /usr/lib/go/src/go/ast/walk.go:385
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/simple.(*Checker).LintMakeLenCap(0xc029ee0b00, 0xc08311a000)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/simple/lint.go:1382 +0xa0
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint.func1(0xc081efe310, 0xc081ab4240, 0xc08311a000)
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:469 +0x102
created by github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint
        /home/wgjak47/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:455 +0x1d6e
 
INFO [runner/max_same_issues] 7/10 issues with text "Error return value of `(*monitor2-go/vendor/github.com/go-xorm/xorm.Session).Find` is not checked" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 2/5 issues with text "Error return value of `io.WriteString` is not checked" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "ineffectual assignment to `ok`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "Error return value of `entityMeasureMap.SetP` is not checked" were hidden, use --max-same-issues 
INFO [runner/max_from_linter] 1/51 issues from linter errcheck were hidden, use --max-issues-per-linter 
INFO [runner] Issues before processing: 152, after processing: 88 
INFO [runner] processing took 12.900123ms with stages: exclude: 5.13654ms, identifier_marker: 3.05502ms, skip_dirs: 1.446095ms, source_code: 985.636µs, autogenerated_exclude: 916.646µs, cgo: 467.989µs, nolint: 412.309µs, path_prettifier: 149.569µs, max_same_issues: 122.4µs, uniq_by_line: 66.27µs, max_per_file_from_linter: 47.33µs, max_from_linter: 32.409µs, path_shortener: 29.69µs, replacement_builder: 28.46µs, diff: 1.56µs, skip_files: 1.26µs, exclude-rules: 940ns 
INFO File cache stats: 39 entries of total size 198.7KiB 
INFO Memory: 35 samples, avg is 1067.8MB, max is 2292.4MB 
INFO Execution took 3.836499293s

@peterhellberg
Copy link

@wgjak47 I'm seeing the same issue with the govet linter under 1.12.1 (on macOS 10.14.3) for f516771

@XenoPhex
Copy link

XenoPhex commented Mar 29, 2019

We're also seeing this error on the cloudfoundry/cli when we enable staticcheck:

$ golangci-lint run
WARN [runner] Panic stack trace: goroutine 12744 [running]:
runtime/debug.Stack(0x193d0a0, 0xc082b86eb0, 0xc0bbd708f8)
	/usr/local/Cellar/go/1.12.1/libexec/src/runtime/debug/stack.go:24 +0x9d
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runLinterSafe.func1(0xc0bbd71ce8, 0xc0bbd71ee0)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/pkg/lint/runner.go:99 +0xfd
panic(0x19130e0, 0xc08af28890)
	/usr/local/Cellar/go/1.12.1/libexec/src/runtime/panic.go:522 +0x1b5
github.com/golangci/go-tools/lint.(*Linter).Lint(0xc0bbd71658, 0xc00911a000, 0x189, 0x200, 0xc0bbd71620, 0x0, 0x0, 0xc0446d36a0)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/lint/lint.go:477 +0x343c
github.com/golangci/golangci-lint/pkg/golinters.runMegacheckCheckers(0xc0446da200, 0x3, 0x4, 0xc00323e870, 0xc00911a000, 0x189, 0x200, 0x4, 0x1989f40, 0x22a8b887a87d4a01, ...)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/megacheck.go:349 +0x1f3
github.com/golangci/golangci-lint/pkg/golinters.megacheck.runMegacheck(0xc000010101, 0xc00911a000, 0x189, 0x200, 0x0, 0xc00323e9f8, 0x100dbc9, 0xc029918810, 0x30, 0x30)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/megacheck.go:303 +0x182
github.com/golangci/golangci-lint/pkg/golinters.megacheck.Run(0x10101, 0x1bfec80, 0xc000a5ac00, 0xc043e9eaf0, 0xc045a7cdc0, 0x1, 0x1, 0x1c07840, 0xc045a7ed40)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/megacheck.go:243 +0xe8
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runLinterSafe(0xc00323eee0, 0x1bfec80, 0xc000a5ac00, 0xc0446ad0a0, 0xc000389080, 0x0, 0x0, 0x0, 0x1be89a0, 0xc082b86eb0)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/pkg/lint/runner.go:105 +0x16a
github.com/golangci/golangci-lint/pkg/lint.Runner.runWorker.func1()
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/pkg/lint/runner.go:139 +0x64
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc0446a46e0, 0x1a40ca2, 0x9, 0xc000073e40)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/pkg/timeutils/stopwatch.go:75 +0x50
github.com/golangci/golangci-lint/pkg/lint.Runner.runWorker(0xc02ca2a7e0, 0x11, 0x11, 0x1c09280, 0xc028f11dd0, 0x1bfec80, 0xc000a5ac00, 0xc0446ad0a0, 0xc046e82780, 0xc046e827e0, ...)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/pkg/lint/runner.go:138 +0x23b
github.com/golangci/golangci-lint/pkg/lint.(*Runner).runWorkers.func1(0xc038f7e5b0, 0xc028eb1fb0, 0x1bfec80, 0xc000a5ac00, 0xc0446ad0a0, 0xc046e82780, 0xc046e827e0, 0xc046e828a0, 0x4, 0x4, ...)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/pkg/lint/runner.go:193 +0x163
created by github.com/golangci/golangci-lint/pkg/lint.(*Runner).runWorkers
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/pkg/lint/runner.go:190 +0x1ab

WARN [runner] Can't run linter megacheck: panic occurred: panic: interface conversion: types.Object is nil, not *types.Func: goroutine 13859 [running]:
runtime/debug.Stack(0xc0b8c89908, 0x192a600, 0xc0674fd7a0)
	/usr/local/Cellar/go/1.12.1/libexec/src/runtime/debug/stack.go:24 +0x9d
github.com/golangci/go-tools/lint.(*Linter).Lint.func1.1(0xc0930b67e0)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/lint/lint.go:458 +0x60
panic(0x192a600, 0xc0674fd7a0)
	/usr/local/Cellar/go/1.12.1/libexec/src/runtime/panic.go:522 +0x1b5
github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated.func1(0x1bf2200, 0xc02c263c80, 0x1bf2801)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/staticcheck/lint.go:2407 +0x647
go/ast.inspector.Visit(0xc06a920d20, 0x1bf2200, 0xc02c263c80, 0x1bea3e0, 0xc06a920d20)
	/usr/local/Cellar/go/1.12.1/libexec/src/go/ast/walk.go:373 +0x3a
go/ast.Walk(0x1bea3e0, 0xc06a920d20, 0x1bf2200, 0xc02c263c80)
	/usr/local/Cellar/go/1.12.1/libexec/src/go/ast/walk.go:52 +0x66
go/ast.walkDeclList(0x1bea3e0, 0xc06a920d20, 0xc02bfc5b00, 0x6, 0x8)
	/usr/local/Cellar/go/1.12.1/libexec/src/go/ast/walk.go:38 +0x9e
go/ast.Walk(0x1bea3e0, 0xc06a920d20, 0x1bf2180, 0xc02bfc5c00)
	/usr/local/Cellar/go/1.12.1/libexec/src/go/ast/walk.go:353 +0x2659
go/ast.Inspect(...)
	/usr/local/Cellar/go/1.12.1/libexec/src/go/ast/walk.go:385
github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated(0xc0446d3660, 0xc0930b67e0)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/staticcheck/lint.go:2448 +0xf3
github.com/golangci/go-tools/lint.(*Linter).Lint.func1(0xc0492e50f0, 0xc02f514000, 0xc0930b67e0)
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/lint/lint.go:469 +0x102
created by github.com/golangci/go-tools/lint.(*Linter).Lint
	/Users/pivotal/go/pkg/mod/github.com/golangci/[email protected]/lint/lint.go:455 +0x1d6e

Notes:

golanci-lint version: 1.15.0
GoLang version: GoLang 1.12.1
Platform: OSX 10.13.6
Config: .golangci.json - just add staticcheck back in.

jirfag added a commit that referenced this issue Mar 31, 2019
jirfag added a commit that referenced this issue Mar 31, 2019
@XenoPhex
Copy link

XenoPhex commented Apr 2, 2019

Just upgraded to 1.16 and I'm getting the same error. Is there anyway to determine which package/files are causing megacheck/staticcheck to fail? Verbose mode isn't as verbose as I was hoping.

@XenoPhex
Copy link

XenoPhex commented Apr 3, 2019

After a few hours of debugging with @ewrenn8, we have determined that this issue is the result of 2 separate problems:

  • The loader is not reading/loading up packages that cannot compile properly. - We determined this by following the stack trace to staticcheck/lint.go:2336/2407. When exploring this line, we determined that the current node was a function from a file that failed to compile. As seen in the stack trace, this causes the ObjectOf function to return a nil value when attempting to lookup that node, triggering the types.Object is nil, not *types.Func panic. We believe ObjectOf returns nil because j.NodePackage(ident).TypesInfo does not contain any of the functions from the package that could not compile.

    A side note into this discovery is that the Loader returns back the following lines in verbose mode:

    INFO [loader] Packages that do not compile: [code.cloudfoundry.org/cli/fixtures/plugins code.cloudfoundry.org/cli/plugin/plugin_examples] 
    

    The ast.Nodes that trigger the panics are all contained within these two packages.

  • Staticcheck is not ignoring files that are listed in the skip-dirs and skip-files section of the config as seen in this comment. - In our config, the non-compiling packages are set to be ignored. These files are not being passed to megacheck as Ignores, thus they are being linted despite not having been loaded up properly.

jirfag added a commit that referenced this issue Apr 21, 2019
The bug was introduced in golangci-lint when migrating staticcheck to go/packages.
Also, thanks to pkg.IllTyped we can analyze as max as we can by
staticcheck.

Relates: #418, #369, #429, #489
jirfag added a commit that referenced this issue Apr 21, 2019
The bug was introduced in golangci-lint when migrating staticcheck to go/packages.
Also, thanks to pkg.IllTyped we can analyze as max as we can by
staticcheck.

Relates: #418, #369, #429, #489
@jirfag
Copy link
Contributor

jirfag commented Apr 21, 2019

Thank you for researching! I've fixed it in #507, please, check.

@jirfag
Copy link
Contributor

jirfag commented Sep 9, 2019

Closing, please, re-open if reproduces.

@jirfag jirfag closed this as completed Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants