-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Under go 1.23, golangci-lint uses all available memory #4909
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
@ldez FYI you're likely to continue to see reports like this come in from homebrew users. golangci-lint v1.60.1 on homebrew was built with go1.22.6
Building from source on go 1.23.0 works as expected. |
I know, it's always the same thing when a new version of Go is released: homebrew uses the previous version of Go. |
How about upgrading the Go version to 1.23.0 in the go.mod file? Then homebrew cannot build golangci-lint on go 1.22, I think. |
It's not possible because golangci-lint needs to be compiled with go1.22 and go1.23. The go version inside the |
I see. |
This also required upgrading golangci-lint due to golangci/golangci-lint#4909
This also required upgrading golangci-lint due to golangci/golangci-lint#4909
Sorry, is it the same thing with nix? |
It depends on your system, and how you build golangci-lint. If golangci-lint v1.60.1 is compiled by go1.23, there is no problem. |
Yeah, I see. Thanks |
We don't need 2 binaries because a binary compiled with go1.23 works with go1.22. Before each release of Go, I create an issue to explain that, the issue about Go1.23 is still pinned. To see the version used to compile:
We are not responsible for package systems that wrongly compile golangci-lint. |
thanks for the explanation 👍 |
Is there a regression here? I downloaded a fresh binary on Mac ARM and I see:
|
No regression, you should use go1.23 to compile golangci-lint if you want to analyze go1.23 code. |
Huh. So I was installing with |
|
@ldez while I agree with your answer that it cannot work. If you know its not supported then the best way would be to fail with message. |
Since v1.60.3 (2024-08-23), there is a log https://golangci-lint.run/product/changelog/#v1603 $ ./golangci-lint run
Error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23)
Failed executing command with error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23) Related to #4938 |
I didnt know that.. My tests all using same linter.
So seems like its not even issue with toolchain but the check only checks the |
build of golangci-lint with go1.22$ export GOTOOLCHAIN=local
$ go version
go version go1.22.9 linux/amd64
$ ./golangci-lint version
golangci-lint has version (devel) built with go1.22.9 from (a1d6c560de1a193a0c68ffed68cd5928ef39e884, modified: false, mod sum: "") on 2024-09-09T14:33:19Z go1.22.x + go.mod 1.22.0 -> OK$ export GOTOOLCHAIN=local
$ go version
go version go1.22.9 linux/amd64
$ golangci-lint cache clean
$ ./golangci-lint run go1.23.x + go.mod 1.22.0 -> OK$ export GOTOOLCHAIN=local
$ go version
go version go1.23.1 linux/amd64
$ golangci-lint cache clean
$ ./golangci-lint run
../../../../../usr/lib/go/src/slices/iter.go:50:17: cannot range over seq (variable of type iter.Seq[E]) (typecheck)
for v := range seq {
^
../../../../../usr/lib/go/src/os/stat_linux.go:47:57: not enough arguments in call to time.Unix
have (unknown type)
want (int64, int64) (typecheck)
return time.Unix(fi.Sys().(*syscall.Stat_t).Atim.Unix()) $ export GOTOOLCHAIN=local
$ go version
go version go1.23.1 linux/amd64
$ export GOTOOLCHAIN=auto
$ go version
go version go1.23.1 linux/amd64
$ golangci-lint cache clean
$ ./golangci-lint run
../../../../../usr/lib/go/src/slices/iter.go:50:17: cannot range over seq (variable of type iter.Seq[E]) (typecheck)
for v := range seq {
^
../../../../../usr/lib/go/src/os/stat_linux.go:47:57: not enough arguments in call to time.Unix
have (unknown type)
want (int64, int64) (typecheck)
return time.Unix(fi.Sys().(*syscall.Stat_t).Atim.Unix()) go1.22.x + go.mod 1.23.0 -> OK$ export GOTOOLCHAIN=local
$ go version
go version go1.22.9 linux/amd64
$ golangci-lint cache clean
$ ./golangci-lint run
ERRO Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: go.mod requires go >= 1.23.0 (running go 1.22.9; GOTOOLCHAIN=local) $ export GOTOOLCHAIN=local
$ go version
go version go1.22.9 linux/amd64
$ export GOTOOLCHAIN=auto
$ go version
go version go1.23.0 linux/amd64
$ golangci-lint cache clean
$ ./golangci-lint run
Error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23.0)
Failed executing command with error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23.0) go1.23.x + go.mod 1.23.0 -> OK$ export GOTOOLCHAIN=local
$ go version
go version go1.23.1 linux/amd64
$ golangci-lint cache clean
$ ./golangci-lint run
Error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23.0)
Failed executing command with error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23.0) go1.22.x + go.mod 1.22.0, toolchain go1.23.1 -> OK$ export GOTOOLCHAIN=local
$ go version
go version go1.22.9 linux/amd64
$ golangci-lint cache clean
$ ./golangci-lint run go1.23.x + go.mod 1.22.0, toolchain go1.23.1 -> OK$ export GOTOOLCHAIN=local
$ go version
go version go1.23.1 linux/amd64
$ golangci-lint cache clean
$ ./golangci-lint run
../../../../../usr/lib/go/src/slices/iter.go:50:17: cannot range over seq (variable of type iter.Seq[E]) (typecheck)
for v := range seq {
^
../../../../../usr/lib/go/src/os/stat_linux.go:47:57: not enough arguments in call to time.Unix
have (unknown type)
want (int64, int64) (typecheck)
return time.Unix(fi.Sys().(*syscall.Stat_t).Atim.Unix()) |
I was able to create repro case.. I found its breaking for You can found all repro files under https://github.com/kentik/.github/pull/1/files https://github.com/kentik/.github/actions/runs/11723589591/job/32655587129 <- killed by GH after 2m when toolchain is set The line thats makes if fail or pass I have also testd without toolchain but with installing go 1.23 and it fails as well see https://github.com/kentik/.github/actions/runs/11723770608/job/32656157617 |
I have no problem even with toolchain. OK$ docker run --rm -v $(pwd):/app -w /app -it golang:1.22.1-alpine sh
/app # go install github.com/golangci/golangci-lint/cmd/[email protected]
...
/app # golangci-lint version
golangci-lint has version v1.61.0 built with go1.22.1 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown)
/app # go version
go version go1.22.1 linux/amd64
/app # golangci-lint run Detailsmodule github.com/golangci/sandbox
go 1.22.0
toolchain go1.23.1
require github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0
require (
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
) |
You have the code on GH. and you see its failing on GH.. |
But your not doing actually |
https://github.com/ldez/cuddly-funicular/actions/runs/11724207066
No, the GOTOOLCHAIN is only used to build golangci-lint, not to run. |
Yup my bad.. but seems that you have it now. |
Build with go1.22 + go.mod 1.22 toolchain go1.23.1
https://github.com/ldez/cuddly-funicular/actions/runs/11724207066 Build with go1.22 + go.mod 1.22 no toolchain
https://github.com/ldez/cuddly-funicular/actions/runs/11724253936 |
So you have your case? |
Something that is not reproducible locally is complex to diagnose. |
why its not reproducible locally? |
This is the question. |
Build with go1.22 + go.mod 1.22 toolchain go1.23.1 + global
So I'm staring to understand. |
The only case (A) that really fails is: build with go1.22 + go.mod 1.22 toolchain go1.23.1 + local Go version 1.23 (global The other case (B) is: build with go1.22 + go.mod 1.22 toolchain go1.23.1 + local Go version 1.22 (with The case (B) is the same as the case (A) because |
So now I can reproduce the problem inside a container: $ docker run --rm -v $(pwd):/app -w /app -it golang:1.23.2-alpine sh
/app # GOTOOLCHAIN=go1.22.1 go install github.com/golangci/golangci-lint/cmd/[email protected]
...
/app # golangci-lint version
golangci-lint has version v1.61.0 built with go1.22.1 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown)
/app # rm -rf /go/pkg/mod/golang.org/toolchain@*
/app # go version
go version go1.23.2 linux/amd64
/app # golangci-lint run
###### High memory and CPU consumption and kill |
I have a fix. |
The fix: #5112 |
Welcome
typecheck
section of the FAQ.Description of the problem
Updating the toolchain line to
1.23.0
ingo.mod
causes the linter to run out of memory. I've duplicated this on both linux x86_64 and darwin arm64. I haven't yet identified which linter is causing the problem, but it's one of the default setVersion of golangci-lint
Configuration
No configuration file or command line arguments passed.
Go environment
Verbose output of running
A minimal reproducible example or link to a public repository
semvertool (golangci-lint-issue branch)
Validation
Supporter
The text was updated successfully, but these errors were encountered: