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

x/tools/go/analysis/passes/{nilness,unusedwrite,buildssa}: some go vet analyzers don't work with generics. #51038

Closed
ldez opened this issue Feb 6, 2022 · 3 comments
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ldez
Copy link

ldez commented Feb 6, 2022

What version of Go are you using (go version)?

$ go version 
go version go1.18beta2 linux/amd64

Does this issue reproduce with the latest release?

It's related to generics.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ldez/.cache/go-build"
GOENV="/home/ldez/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ldez/sources/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ldez/sources/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/ldez/.gvm/gos/go1.18beta2"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/ldez/.gvm/gos/go1.18beta2/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18beta2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2068066531=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I use the following analyzers:

These 3 analyzers are related to the support of generics in the SSA package #48525.

Related to #48704 and #50558

What did you expect to see?

No panic.

What did you see instead?

ERRO [runner] Panic: unusedwrite: package "sandbox" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildssa.SSA: goroutine 896 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x65
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x155
panic({0x134e7c0, 0xc000886810})
        runtime/panic.go:838 +0x207
golang.org/x/tools/go/analysis/passes/unusedwrite.run(0x13307c0?)
        golang.org/x/tools@v0.1.9/go/analysis/passes/unusedwrite/unusedwrite.go:74 +0x166
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc000b256c0)
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:187 +0x9c4
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x1d
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc000210280, {0x14b92e6, 0xb}, 0xc00069d748)
        github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4a
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc00112af00?)
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:104 +0x85
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc000b256c0)
        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 +0x1eb
ERRO [runner] Panic: nilness: package "sandbox" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildssa.SSA: goroutine 949 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x65
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x155
panic({0x134e7c0, 0xc000c5e060})
        runtime/panic.go:838 +0x207
golang.org/x/tools/go/analysis/passes/nilness.run(0xc00245e270)
        golang.org/x/tools@v0.1.9/go/analysis/passes/nilness/nilness.go:64 +0xad
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0016d6a50)
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:187 +0x9c4
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x1d
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc000586820, {0x146d160, 0x7}, 0xc00179cf48)
        github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4a
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc000251980?)
        github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:104 +0x85
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc0016d6a50)
        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 +0x1eb 
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Feb 6, 2022
@gopherbot gopherbot added this to the Unreleased milestone Feb 6, 2022
@dominikh
Copy link
Member

dominikh commented Feb 6, 2022

I would consider this a duplicate of #48525. Do you agree?

@ldez
Copy link
Author

ldez commented Feb 6, 2022

The problem is related to x/tools/go/ssa but nilness, unusedwrite are not in the package x/tools/go/ssa.
So I don't know what is the best approach to track this.
If you think that #48525 is enough, you can consider this issue as a duplicate.

@timothy-king
Copy link
Contributor

IMO this is a duplicate of #48525.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants