Skip to content

go-critic/go-ruleguard: issues running under 1.20 #3586

@mpldr

Description

@mpldr

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 (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

Since Go 1.20 has been released our CI-Pipelines have been failing.

Before updating golangci-lint: https://builds.sr.ht/~rjarry/job/938148#bottom
After updating golangci-lint: https://builds.sr.ht/~rjarry/job/938728#bottom

Version of golangci-lint

before updating
$ go run github.com/golangci/golangci-lint/cmd/golangci-lint --version
golangci-lint has version v1.49.0 built from (unknown, mod sum: "h1:I8WHOavragDttlLHtSraHn/h39C+R60bEQ5NoGcHQr8=") on (unknown)
after updating
$ go run github.com/golangci/golangci-lint/cmd/golangci-lint --version
# github.com/quasilyte/go-ruleguard/ruleguard
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:26:50: undefined: gogrep.ExprSlice
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:102:50: undefined: gogrep.ExprSlice
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:118:50: undefined: gogrep.ExprSlice
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:134:50: undefined: gogrep.ExprSlice
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:150:50: undefined: gogrep.ExprSlice
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:166:50: undefined: gogrep.ExprSlice
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:215:50: undefined: gogrep.ExprSlice
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:325:51: undefined: gogrep.ExprSlice
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:339:50: undefined: gogrep.ExprSlice
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:354:50: undefined: gogrep.ExprSlice
../../go/pkg/mod/github.com/quasilyte/[email protected]/ruleguard/filters.go:354:50: too many errors

Configuration file

[run]
# include notmuch codes
build-tags = ["notmuch"]
# don't lint tests
tests = false

# enable additional linters
[linters]
enable = [
	"nolintlint", # nolint comments require justification
	"errorlint", # check to ensure no problems with wrapped errors
	"gocritic", # check for bugs, performance, and style issues
	"gofmt", # check that gofmt is satisfied
	"aerc", # aerc specific linters
]

[linters-settings.nolintlint]
allow-unused = false # don't allow nolint if not required
require-explanation = true # require an explanation when disabling a linter
requre-specific = true # linter exceptions must specify the linter

[linters-settings.custom.aerc]
path = "./linters.so"
description = "Aerc specific linters"
original-url = "git.sr.ht/~rjarry/aerc/contrib"

I could confirm that it is not our custom linter by simply commenting it out.

Go environment

$ go version && go env
go version go1.20 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/moritz/.cache/go-build"
GOENV="/home/moritz/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS="-buildmode=exe"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/moritz/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/moritz/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/moritz/Projects/aerc/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1460030550=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/moritz/Projects/aerc /home/moritz/Projects /home/moritz /home /] 
INFO [config_reader] Used config file .golangci.toml 
INFO Loaded ./linters.so: aerc                    
INFO [lintersdb] Active 12 linters: [aerc errcheck errorlint gocritic gofmt gosimple govet ineffassign nolintlint staticcheck typecheck unused] 
INFO [loader] Using build tags: [notmuch]         
INFO [loader] Go packages loading at mode 575 (name|types_sizes|exports_file|imports|files|compiled_files|deps) took 4.030049273s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 27.016957ms 
INFO [linters context/goanalysis] analyzers took 19.418302818s with top 10 stages: buildir: 9.787908911s, inspect: 774.095103ms, gocritic: 726.029768ms, printf: 453.533038ms, S1038: 432.540959ms, ctrlflow: 391.58769ms, SA5012: 387.209183ms, fact_deprecated: 387.191565ms, fact_purity: 381.178701ms, typedness: 377.225837ms 
ERRO [runner] Panic: buildir: package "netip" (isInitialPkg: false, needAnalyzeSource: true): in net/netip.AddrFromSlice: cannot convert Load <[]byte> t0 ([]byte) to [4]byte: goroutine 4313 [running]:
runtime/debug.Stack()
	/usr/lib/go/src/runtime/debug/stack.go:24 +0x65
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
	/home/moritz/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:101 +0x155
panic({0x14da180, 0xc003790240})
	/usr/lib/go/src/runtime/panic.go:884 +0x213
honnef.co/go/tools/go/ir.emitConv(0xc004553540, {0x190e788, 0xc004619800}, {0x1901d40?, 0xc00089a7b0}, {0x1901430, 0xc00378a580})
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/emit.go:293 +0xd29
honnef.co/go/tools/go/ir.(*builder).expr0(0xc010855a28, 0xc004553540, {0x19050d0?, 0xc00378a580?}, {0x7, {0x1901d40, 0xc00089a7b0}, {0x0, 0x0}})
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:610 +0x5d7
honnef.co/go/tools/go/ir.(*builder).expr(0x1901ed0?, 0xc004553540, {0x19050d0, 0xc00378a580})
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:566 +0x1fa
honnef.co/go/tools/go/ir.(*builder).emitCallArgs(0x1901ed0?, 0xc004553540, 0xc00b56d5c0, 0xc00378a5c0, {0x0?, 0x0, 0x8b00a7?})
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:975 +0x135
honnef.co/go/tools/go/ir.(*builder).setCall(0x1543440?, 0xc004553540, 0xc00378a5c0, 0xc005b00e08)
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:1037 +0x8e
honnef.co/go/tools/go/ir.(*builder).expr0(0xc010855a28, 0xc004553540, {0x19050d0?, 0xc00378a5c0?}, {0x7, {0x1901e30, 0xc005166230}, {0x0, 0x0}})
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:623 +0x218e
honnef.co/go/tools/go/ir.(*builder).expr(0xc010854e78?, 0xc004553540, {0x19050d0, 0xc00378a5c0})
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:566 +0x1fa
honnef.co/go/tools/go/ir.(*builder).stmt(0xc004553540?, 0xc004553540, {0x1905610?, 0xc011128520?})
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:2291 +0x194c
honnef.co/go/tools/go/ir.(*builder).stmtList(...)
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:855
honnef.co/go/tools/go/ir.(*builder).switchStmt(0xc010855308?, 0xc004553540, 0xc0022d9650, 0x0)
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:1366 +0x19a5
honnef.co/go/tools/go/ir.(*builder).stmt(0x20?, 0xc004553540, {0x1905760?, 0xc0022d9650?})
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:2365 +0x121c
honnef.co/go/tools/go/ir.(*builder).stmtList(0x8b6a25?, 0xc0108554f8?, {0xc011128700?, 0x2, 0x8b8630?})
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:855 +0x45
honnef.co/go/tools/go/ir.(*builder).stmt(0xc004553540?, 0xc004553540, {0x1905070?, 0xc0022d9680?})
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:2338 +0x9b9
honnef.co/go/tools/go/ir.(*builder).buildFunction(0xc010855a28, 0xc004553540)
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:2450 +0x3d7
honnef.co/go/tools/go/ir.(*builder).buildFuncDecl(0x0?, 0xc00ab0f4d0, 0xc0022d9950)
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:2488 +0x19b
honnef.co/go/tools/go/ir.(*Package).build(0xc00ab0f4d0)
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:2594 +0xc16
sync.(*Once).doSlow(0xc004dcbce0?, 0xc003c10780?)
	/usr/lib/go/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
	/usr/lib/go/src/sync/once.go:65
honnef.co/go/tools/go/ir.(*Package).Build(...)
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/go/ir/builder.go:2512
honnef.co/go/tools/internal/passes/buildir.run(0xc0038df520)
	/home/moritz/go/pkg/mod/honnef.co/go/[email protected]/internal/passes/buildir/buildir.go:86 +0x368
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0032805e0)
	/home/moritz/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:187 +0x9d6
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
	/home/moritz/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:105 +0x1d
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc001d14730, {0x16a31cb, 0x7}, 0xc0022e4748)
	/home/moritz/go/pkg/mod/github.com/golangci/[email protected]/pkg/timeutils/stopwatch.go:111 +0x4a
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc00290fda0?)
	/home/moritz/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:104 +0x85
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc0032805e0)
	/home/moritz/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb4
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
	/home/moritz/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1eb 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: buildir: package "netip" (isInitialPkg: false, needAnalyzeSource: true): in net/netip.AddrFromSlice: cannot convert Load <[]byte> t0 ([]byte) to [4]byte 
INFO [runner] processing took 3.068µs with stages: max_same_issues: 471ns, nolint: 301ns, skip_dirs: 280ns, cgo: 271ns, max_from_linter: 190ns, exclude-rules: 181ns, source_code: 181ns, identifier_marker: 120ns, max_per_file_from_linter: 120ns, skip_files: 120ns, exclude: 111ns, uniq_by_line: 111ns, filename_unadjuster: 111ns, severity-rules: 110ns, autogenerated_exclude: 110ns, path_prettifier: 110ns, diff: 50ns, sort_results: 40ns, path_prefixer: 40ns, path_shortener: 40ns 
INFO [runner] linters took 3.203039529s with stages: goanalysis_metalinter: 3.203001186s 
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: goanalysis_metalinter: buildir: package "netip" (isInitialPkg: false, needAnalyzeSource: true): in net/netip.AddrFromSlice: cannot convert Load <[]byte> t0 ([]byte) to [4]byte
 
INFO Memory: 74 samples, avg is 306.6MB, max is 1648.7MB 
INFO Execution took 7.265989136s                  
exit status 3

not compiling after updating to 1.51.1

Code example or link to a public repository

https://git.sr.ht/~rjarry/aerc

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdependenciesRelates to an upstream dependency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions