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

Go 1.18: Panic: buildir: package "provider" #2664

Closed
4 tasks done
andig opened this issue Mar 20, 2022 · 8 comments
Closed
4 tasks done

Go 1.18: Panic: buildir: package "provider" #2664

andig opened this issue Mar 20, 2022 · 8 comments
Labels
question Further information is requested

Comments

@andig
Copy link

andig commented Mar 20, 2022

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

Linting panics:

❯ make lint
golangci-lint run
ERRO [runner] Panic: buildir: package "provider" (isInitialPkg: false, needAnalyzeSource: true): T: goroutine 15062 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x68
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x104
panic({0x10347b000, 0x14004251620})
	runtime/panic.go:838 +0x204
honnef.co/go/tools/go/ir.(*Program).needMethods(0x14001a620e0, {0x1034e1688?, 0x14004251620?}, 0x0)
	honnef.co/go/[email protected]/go/ir/methods.go:237 +0x524
honnef.co/go/tools/go/ir.(*Program).needMethods(0x14001a620e0, {0x1034e1660?, 0x140078a9440?}, 0x0)
	honnef.co/go/[email protected]/go/ir/methods.go:233 +0x600
honnef.co/go/tools/go/ir.(*Program).needMethods(0x14001a620e0, {0x1034e15c0?, 0x140078cb1c0?}, 0x0)
	honnef.co/go/[email protected]/go/ir/methods.go:210 +0x3e8
honnef.co/go/tools/go/ir.(*Program).needMethods(0x14001a620e0, {0x1034e1660?, 0x140078a9470?}, 0x0)
	honnef.co/go/[email protected]/go/ir/methods.go:233 +0x600
honnef.co/go/tools/go/ir.(*Program).needMethods(0x14001a620e0, {0x1034e15c0?, 0x140078cb140?}, 0x0)
	honnef.co/go/[email protected]/go/ir/methods.go:209 +0x3cc
honnef.co/go/tools/go/ir.(*Program).needMethodsOf(0x14005ae3af0?, {0x1034e15c0?, 0x140078cb140?})
	honnef.co/go/[email protected]/go/ir/methods.go:145 +0xb4
honnef.co/go/tools/go/ir.(*Package).build(0x140082fbc20)
	honnef.co/go/[email protected]/go/ir/builder.go:2375 +0xd8
sync.(*Once).doSlow(0x14001a620e0?, 0x140078b4000?)
	sync/once.go:68 +0x10c
sync.(*Once).Do(...)
	sync/once.go:59
honnef.co/go/tools/go/ir.(*Package).Build(...)
	honnef.co/go/[email protected]/go/ir/builder.go:2363
honnef.co/go/tools/internal/passes/buildir.run(0x1400858c820)
	honnef.co/go/[email protected]/internal/passes/buildir/buildir.go:86 +0x28c
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0x14003332320)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:187 +0x96c
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x24
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0x14000aafea0, {0x10307f191, 0x7}, 0x14002b76f30)
	github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x48
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0x102c64e00?)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:104 +0x78
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0x14003332320)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb4
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x16c
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: buildir: package "provider" (isInitialPkg: false, needAnalyzeSource: true): T
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: goanalysis_metalinter: buildir: package "provider" (isInitialPkg: false, needAnalyzeSource: true): T

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.45.0 built from 1f4c1ed on 2022-03-18T14:35:36Z```

Configuration file

$ cat .golangci.yml
issues:
  exclude:
  - .regActualCurrent. is unused
  - "`routeLogger` is unused"

Go environment

$ go version && go envgo version && go env
go version go1.18 darwin/arm64
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/andig/Library/Caches/go-build"
GOENV="/Users/andig/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andig/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andig/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.18/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.18/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/andig/htdocs/evcc/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build1021287890=/tmp/go-build -gno-record-gcc-switches -fno-common"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -vgolangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/andig/htdocs/evcc /Users/andig/htdocs /Users/andig /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (imports|deps|exports_file|name|types_sizes|compiled_files|files) took 1.30858525s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 12.684708ms
INFO [linters context/goanalysis] analyzers took 32.382452156s with top 10 stages: buildir: 17.937472259s, fact_deprecated: 1.573165623s, inspect: 1.345512898s, printf: 1.162804344s, ctrlflow: 889.364007ms, nilness: 852.838036ms, fact_purity: 683.247877ms, typedness: 543.268471ms, SA5012: 408.588546ms, directives: 176.904082ms
ERRO [runner] Panic: buildir: package "provider" (isInitialPkg: false, needAnalyzeSource: true): T: goroutine 23246 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x68
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x104
panic({0x103547000, 0x14019e57c20})
	runtime/panic.go:838 +0x204
honnef.co/go/tools/go/ir.(*Program).needMethods(0x140079d4d20, {0x1035ad688?, 0x14019e57c20?}, 0x0)
	honnef.co/go/[email protected]/go/ir/methods.go:237 +0x524
honnef.co/go/tools/go/ir.(*Program).needMethods(0x140079d4d20, {0x1035ad660?, 0x1400fdedd70?}, 0x0)
	honnef.co/go/[email protected]/go/ir/methods.go:233 +0x600
honnef.co/go/tools/go/ir.(*Program).needMethods(0x140079d4d20, {0x1035ad5c0?, 0x1400de7b340?}, 0x0)
	honnef.co/go/[email protected]/go/ir/methods.go:210 +0x3e8
honnef.co/go/tools/go/ir.(*Program).needMethods(0x140079d4d20, {0x1035ad660?, 0x1400fdedda0?}, 0x0)
	honnef.co/go/[email protected]/go/ir/methods.go:233 +0x600
honnef.co/go/tools/go/ir.(*Program).needMethods(0x140079d4d20, {0x1035ad5c0?, 0x1400de7b2c0?}, 0x0)
	honnef.co/go/[email protected]/go/ir/methods.go:209 +0x3cc
honnef.co/go/tools/go/ir.(*Program).needMethodsOf(0x1400410e690?, {0x1035ad5c0?, 0x1400de7b2c0?})
	honnef.co/go/[email protected]/go/ir/methods.go:145 +0xb4
honnef.co/go/tools/go/ir.(*Package).build(0x1401f6a2360)
	honnef.co/go/[email protected]/go/ir/builder.go:2375 +0xd8
sync.(*Once).doSlow(0x140079d4d20?, 0x140198d14f0?)
	sync/once.go:68 +0x10c
sync.(*Once).Do(...)
	sync/once.go:59
honnef.co/go/tools/go/ir.(*Package).Build(...)
	honnef.co/go/[email protected]/go/ir/builder.go:2363
honnef.co/go/tools/internal/passes/buildir.run(0x1401fc304e0)
	honnef.co/go/[email protected]/internal/passes/buildir/buildir.go:86 +0x28c
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0x14002966700)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:187 +0x96c
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x24
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0x14000120a00, {0x10314b191, 0x7}, 0x14001793730)
	github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x48
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0x102d30e00?)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:104 +0x78
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0x14002966700)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb4
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x16c
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: buildir: package "provider" (isInitialPkg: false, needAnalyzeSource: true): T
INFO [runner] processing took 2.624µs with stages: max_same_issues: 625ns, max_from_linter: 292ns, nolint: 250ns, cgo: 250ns, skip_files: 209ns, skip_dirs: 167ns, filename_unadjuster: 125ns, max_per_file_from_linter: 83ns, identifier_marker: 83ns, exclude: 83ns, path_shortener: 83ns, path_prettifier: 83ns, exclude-rules: 42ns, severity-rules: 42ns, path_prefixer: 42ns, uniq_by_line: 42ns, autogenerated_exclude: 41ns, source_code: 41ns, sort_results: 41ns, diff: 0s
INFO [runner] linters took 4.732210875s with stages: goanalysis_metalinter: 4.732177375s
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: goanalysis_metalinter: buildir: package "provider" (isInitialPkg: false, needAnalyzeSource: true): T

INFO Memory: 62 samples, avg is 585.2MB, max is 854.8MB
INFO Execution took 6.060550333s

Code example or link to a public repository

Code is here: evcc-io/evcc#2116

@andig andig added the bug Something isn't working label Mar 20, 2022
@ldez
Copy link
Member

ldez commented Mar 20, 2022

Hello,

As I explained here and here, if you are using generics you have to set the following configuration:

run:
    go: 1.18

https://golangci-lint.run/usage/configuration/#run-configuration

@ldez ldez closed this as completed Mar 20, 2022
@ldez ldez added question Further information is requested and removed bug Something isn't working labels Mar 20, 2022
@andig
Copy link
Author

andig commented Mar 21, 2022

@ldez I have now specified as requested but panic remains the same:

run:
  go: 1.18
issues:
  exclude:
  - .regActualCurrent. is unused
  - "`routeLogger` is unused"

Reopen?

@ldez
Copy link
Member

ldez commented Mar 21, 2022

Your panic (in the description and in your CI) is related to staticcheck (honnef.co/go/tools), staticcheck is disabled when you set go: 1.18.

So check your setup, and provide your stack if you still have the same problem.

@andig
Copy link
Author

andig commented Mar 21, 2022

Sorry for the noise. I had renamed golangci.yaml to golangci-lint.yaml and it wasn't picked up.

I've also noticed that structcheck returns amounts of false is unused positives now- new issue?

@ldez
Copy link
Member

ldez commented Mar 21, 2022

I've also noticed that structcheck returns amounts of false is unused positives now- new issue?

It's already fixed but not available for now. #2666

@wafer-bw
Copy link

wafer-bw commented Apr 6, 2022

To those experiencing this issue on go1.17 try changing uses: golangci/golangci-lint-action@v2 to uses: golangci/golangci-lint-action@v3 and make sure you're using >= version: v1.45

@muir
Copy link

muir commented Apr 20, 2022

If you're not using a config file, adding --go=1.18 seems to work around the issue:

golangci-lint run --go=1.18

Of course, that turns off a bunch of linters. Is there a way to pretend to use go 1.17 for linting purposes?

@ldez
Copy link
Member

ldez commented Apr 21, 2022

@muir everything is explained here: #2649

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants