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-critic: checkers.init panic with go1.19beta1 #2922

Closed
4 tasks done
kolyshkin opened this issue Jun 16, 2022 · 6 comments · Fixed by #3037
Closed
4 tasks done

go-critic: checkers.init panic with go1.19beta1 #2922

kolyshkin opened this issue Jun 16, 2022 · 6 comments · Fixed by #3037
Labels
bug Something isn't working

Comments

@kolyshkin
Copy link
Contributor

kolyshkin commented Jun 16, 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

When I try to use golangci-lint with go 1.19beta1 in GHA CI, I get:

Running [/home/runner/golangci-lint-1.46.2-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
panic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt
  
  goroutine 1 [running]:
  github.com/go-critic/go-critic/checkers.init.22()
  	github.com/go-critic/[email protected]/checkers/embedded_rules.go:47 +0x4b4

Version of golangci-lint

1.46.2

Configuration file

not relevant

Go environment

$ go env
# paste output here

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/runner/.cache/go-build"
GOENV="/home/runner/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/runner/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/runner/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/hostedtoolcache/go/1.19.0-beta.1/x64"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/hostedtoolcache/go/1.19.0-beta.1/x64/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19beta1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/runner/work/runc/runc/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build513076706=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

n/a

Code example or link to a public repository

See https://github.com/opencontainers/runc/runs/6923780174?check_suite_focus=true

opencontainers/runc#3514

@kolyshkin kolyshkin added the bug Something isn't working label Jun 16, 2022
@ldez ldez changed the title go 1.19 compatibility go-critic: checkers.init panic on go1.19 Jun 16, 2022
@ldez ldez changed the title go-critic: checkers.init panic on go1.19 go-critic: checkers.init panic with go1.19-beta1 Jun 16, 2022
@ldez ldez changed the title go-critic: checkers.init panic with go1.19-beta1 go-critic: checkers.init panic with go1.19beta1 Jun 16, 2022
@ldez
Copy link
Member

ldez commented Jun 16, 2022

Hello,

Have you tried to run go-critic as a binary?

@ldez
Copy link
Member

ldez commented Jun 16, 2022

I tried locally with go1.19beta1, and it works.

IMO it's a duplicate of #2673

$ git clone [email protected]:opencontainers/runc.git    
Cloning into 'runc'...
remote: Enumerating objects: 35414, done.
remote: Counting objects: 100% (292/292), done.
remote: Compressing objects: 100% (153/153), done.
remote: Total 35414 (delta 164), reused 227 (delta 133), pack-reused 35122
Receiving objects: 100% (35414/35414), 15.72 MiB | 5.56 MiB/s, done.
Resolving deltas: 100% (23351/23351), done.
$ cd runc
$ go version        
go version go1.19beta1 linux/amd64
$ golangci-lint run  
libcontainer/factory_linux.go:230:59: SA9008: e refers to the result of a failed type assertion and is a zero value, not the value that was being type-asserted (staticcheck)
                                err = fmt.Errorf("panic from initialization: %v, %s", e, debug.Stack())
                                                                                      ^
libcontainer/factory_linux.go:226:7: SA9008(related information): this is the variable being read (staticcheck)
                        if e, ok := e.(error); ok {
                           ^

@kolyshkin
Copy link
Contributor Author

Hello,

Have you tried to run go-critic as a binary?

Gocritic is not even enabled (nor do I need it).

Also, the same setup works fine in CI with either go 1.16.x or go 1.17.x.

I tried locally with go1.19beta1, and it works.

Does not work for me. Here's a complete repro:

[kir@kir-rhat runc]$  go install golang.org/dl/go1.19beta1@latest
go: downloading golang.org/dl v0.0.0-20220609182932-6cd2f0e318f7
[kir@kir-rhat runc]$ go1.19beta1 download
<...skip....>
[kir@kir-rhat runc]$ ln -s /home/kir/go/bin/go1.19beta1 /home/kir/bin/go
[kir@kir-rhat runc]$ which go
~/bin/go
[kir@kir-rhat runc]$ go version
go version go1.19beta1 linux/amd64
[kir@kir-rhat runc]$ golangci-lint run ./...
panic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt

goroutine 1 [running]:
github.com/go-critic/go-critic/checkers.init.22()
	github.com/go-critic/[email protected]/checkers/embedded_rules.go:47 +0x4b4
[kir@kir-rhat runc]$ golangci-lint version
panic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt

goroutine 1 [running]:
github.com/go-critic/go-critic/checkers.init.22()
	github.com/go-critic/[email protected]/checkers/embedded_rules.go:47 +0x4b4

@ldez
Copy link
Member

ldez commented Jun 16, 2022

Gocritic is not even enabled (nor do I need it).

go-critic uses an init function you cannot disable that.

https://github.com/go-critic/go-critic/blob/bf8c01ca6692a5a3e8c20b1caef47dfab1412c88/checkers/embedded_rules.go#L18

go-critic/go-critic#1218

@rhcarvalho
Copy link

IMO it's a duplicate of #2673

This also seems like a dup for me.

In case anyone lands here, I managed to use Go 1.19 + golangci-lint v1.47.3 by building from source, see #2673 (comment).

@ldez ldez mentioned this issue Aug 3, 2022
@ldez ldez closed this as completed in #3037 Aug 3, 2022
@gliptak
Copy link

gliptak commented Aug 3, 2022

go-critic/go-critic#1157

kolyshkin added a commit to kolyshkin/runc that referenced this issue Aug 4, 2022
This version works with go 1.19, i.e. it fixes
golangci/golangci-lint#2922.

Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin added a commit to kolyshkin/runc that referenced this issue Aug 4, 2022
This version works with go 1.19, i.e. it fixes
golangci/golangci-lint#2922.

Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin added a commit to kolyshkin/runc that referenced this issue Aug 16, 2022
This version works with go 1.19, i.e. it fixes
golangci/golangci-lint#2922.

Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin added a commit to kolyshkin/runc that referenced this issue Mar 28, 2023
This version works with go 1.19, i.e. it fixes
golangci/golangci-lint#2922.

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 0f4bf2c)
Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin added a commit to kolyshkin/runc that referenced this issue Apr 4, 2023
This version works with go 1.19, i.e. it fixes
golangci/golangci-lint#2922.

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 0f4bf2c)
Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin added a commit to kolyshkin/runc that referenced this issue Apr 5, 2023
This version works with go 1.19, i.e. it fixes
golangci/golangci-lint#2922.

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 0f4bf2c)
Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin added a commit to kolyshkin/runc that referenced this issue Apr 5, 2023
This version works with go 1.19, i.e. it fixes
golangci/golangci-lint#2922.

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 0f4bf2c)
Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin added a commit to kolyshkin/runc that referenced this issue Apr 5, 2023
This version works with go 1.19, i.e. it fixes
golangci/golangci-lint#2922.

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 0f4bf2c)
Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin added a commit to kolyshkin/runc that referenced this issue Apr 5, 2023
This version works with go 1.19, i.e. it fixes
golangci/golangci-lint#2922.

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 0f4bf2c)
Signed-off-by: Kir Kolyshkin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants