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 in unused linter when used with govet #1980

Closed
3 tasks done
dangogh opened this issue May 13, 2021 · 3 comments
Closed
3 tasks done

panic in unused linter when used with govet #1980

dangogh opened this issue May 13, 2021 · 3 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@dangogh
Copy link

dangogh commented May 13, 2021

  • 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).
  • [n/a] Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)
panic in `unused` linter, but only when used with `govet`

The following command on the code below produces a panic:

golangci-lint run --no-config --disable-all -E unused,govet snippet.go

Note that no config file is used and only 2 linters are invoked.

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.40.0 built from 5c6adb63 on 2021-05-10T10:45:21Z
Config file

--no-config option is used.

Go environment
$ go version && go env
go version go1.16.4 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dkirkwood/Library/Caches/go-build"
GOENV="/Users/dkirkwood/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/dkirkwood/go/pkg/mod"
GONOPROXY="<redacted>"
GONOSUMDB="<redacted>"
GOOS="darwin"
GOPATH="/Users/dkirkwood/go"
GOPRIVATE="<redacted>"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/dkirkwood/.gimme/versions/go1.16.4.darwin.amd64"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/dkirkwood/.gimme/versions/go1.16.4.darwin.amd64/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/dkirkwood/go/src/<redacted>"
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 x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/r0/j7g4vqkn1b38byz_tbq6kd3x024xwl/T/go-build1798230173=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
golangci-lint run --no-config --disable-all -E unused,govet snippet.go  -v
INFO [lintersdb] Active 2 linters: [govet unused]
INFO [loader] Go packages loading at mode 575 (types_sizes|deps|exports_file|files|imports|compiled_files|name) took 217.62132ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 212.578µs
INFO [linters context/goanalysis] analyzers took 2.178072ms with top 10 stages: printf: 354.13µs, ctrlflow: 272.487µs, testinggoroutine: 145.332µs, stringintconv: 145.269µs, httpresponse: 141.118µs, shift: 128.927µs, copylocks: 118.984µs, sigchanyzer: 114.818µs, bools: 106.224µs, stdmethods: 101.222µs
WARN [linters context] Panic: unused: package "snippet" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildir.IR: goroutine 354 [running]:
runtime/debug.Stack(0x1df377c, 0x3c, 0xc0004f3640)
	runtime/debug/stack.go:24 +0x9f
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1(0xc0002f3490)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x1be
panic(0x1c014e0, 0xc000700b10)
	runtime/panic.go:965 +0x1b9
honnef.co/go/tools/unused.run(0xc0004a0340, 0xc001656001, 0x1490f, 0x17fff, 0x40000006)
	honnef.co/go/[email protected]/unused/unused.go:504 +0x6b1
github.com/golangci/golangci-lint/pkg/golinters.NewUnused.func1(0xc0004a0340, 0x15ba0257, 0x26b3120, 0xc000190458, 0x2)
	github.com/golangci/golangci-lint/pkg/golinters/unused.go:31 +0x69
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0002f3490)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:187 +0x9f2
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x2a
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc0004ad400, 0x1d3fb58, 0x6, 0xc000628f70)
	github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4d
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc0002f3490)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:104 +0x91
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc000b67700, 0xc0002f3490)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x65
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x316
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: unused: package "snippet" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildir.IR
INFO [runner] processing took 3.246µs with stages: max_same_issues: 532ns, skip_dirs: 375ns, nolint: 304ns, autogenerated_exclude: 216ns, max_from_linter: 209ns, cgo: 183ns, identifier_marker: 179ns, uniq_by_line: 179ns, filename_unadjuster: 160ns, skip_files: 154ns, diff: 140ns, path_prettifier: 140ns, max_per_file_from_linter: 68ns, exclude: 61ns, source_code: 61ns, sort_results: 60ns, path_shortener: 57ns, severity-rules: 57ns, exclude-rules: 56ns, path_prefixer: 55ns
INFO [runner] linters took 70.086412ms with stages: goanalysis_metalinter: 70.045525ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 4 samples, avg is 71.7MB, max is 72.1MB
INFO Execution took 298.566774ms
Code example or link to a public repository
package snippet

import (
	"os"
	"os/signal"
)

type A struct{}

func (a *A) Doit() {
	signals := make(chan os.Signal)
	signal.Notify(signals, os.Interrupt, os.Kill)
}
@dangogh dangogh added the bug Something isn't working label May 13, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented May 13, 2021

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez
Copy link
Member

ldez commented May 13, 2021

Duplicate of #1973

@ldez ldez marked this as a duplicate of #1973 May 13, 2021
@ldez ldez closed this as completed May 13, 2021
@ldez ldez added the duplicate This issue or pull request already exists label May 13, 2021
@dangogh
Copy link
Author

dangogh commented May 13, 2021

ahh.. thanks @ldez . I did look for duplicates, but missed that one. Glad I'm not the only one to hit it..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants