golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
15.66k stars 1.39k forks source link

When running the linter, my PC crashes or the linter dies #4933

Closed PatricioPoncini closed 2 months ago

PatricioPoncini commented 2 months ago

Welcome

Description of the problem

Hi, for some reason, updating the golint version is causing my PC to crash. Essentially, the PC freezes and I can do nothing but restart it. I have tried this multiple times, and the result is always the same: either the PC crashes or the process is canceled and dies. I have updated the library, golang, and cleared the cache. I don't know what else could be causing this problem. Has anyone else experienced this?

Version of golangci-lint

```console $ golangci-lint --version golangci-lint has version v1.60.2 built with go1.22.3 from (unknown, modified: ?, mod sum: "h1:Y8aWnZCMOLY5T7Ga5hcoemyKsZZJCUmIIK3xTD3jIhc=") on (unknown) ```

Configuration

```console run: timeout: 5m output: sort-results: true linters: enable: - asciicheck - dogsled - durationcheck - errcheck - errorlint - gofumpt - exportloopref --> i will change this - gofmt - goimports - gosec - misspell - nakedret - nilerr - nolintlint - revive - wastedassign - gocritic - godot - predeclared - unused - testifylint linters-settings: testifylint: enable-all: true gofumpt: extra-rules: true gosec: includes: - G102 - G106 - G108 - G109 - G111 - G112 - G201 - G203 issues: exclude-rules: - linters: - structcheck - unused text: '`data` is unused' - linters: - revive text: 'var-naming:' - linters: - revive text: 'exported:' - path: _test\.go linters: - gosec - linters: - revive path: _test\.go ```

Go environment

```console $ go version && go env > go version go version go1.22.3 linux/amd64 ~ > go env GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/home/tripa/.cache/go-build' GOENV='/home/tripa/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/home/tripa/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/tripa/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/usr/local/go' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.22.3' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='gcc' CXX='g++' CGO_ENABLED='1' GOMOD='/dev/null' 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 -ffile-prefix-map=/tmp/go-build3016261960=/tmp/go-build -gno-record-gcc-switches' ```

Verbose output of running

```console $ golangci-lint cache clean $ golangci-lint run -v INFO golangci-lint has version v1.60.2 built with go1.22.3 from (unknown, modified: ?, mod sum: "h1:Y8aWnZCMOLY5T7Ga5hcoemyKsZZJCUmIIK3xTD3jIhc=") on (unknown) INFO [config_reader] Config search paths: [./ /home/tripa/legendaryum/legend-missions /home/tripa/legendaryum /home/tripa /home /] INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused] INFO [loader] Go packages loading at mode 575 (deps|files|imports|types_sizes|compiled_files|exports_file|name) took 156.586852ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 4.9006ms [1] 29569 killed golangci-lint run -v ```

A minimal reproducible example or link to a public repository

```go // The error is not in the code, but in the linter. ```

Validation

Supporter

boring-cyborg[bot] commented 2 months ago

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

AntWDev commented 2 months ago

Myself (v1.59.1) and my colleague (v1.60.1) are also experiencing this

AntWDev commented 2 months ago

Running top while running golangci-lint shows the memory usage consistently increasing until being killed by OOM or freezing the VM

csatib02 commented 2 months ago

Hey,

We experience the same weird behaviour since upgrading to go 1.23.0 when using golangci-lint. On our pipeline we observed significant increase in golangci-lint run time which eventually ends in the process getting killed: https://github.com/bank-vaults/secret-init/actions/runs/10492750198/job/29065017771?pr=227

Locally sometimes you get a successful run.

MoJoE3131 commented 2 months ago

Just tested and it seems somehow linked to go 1.23.0 as stated by @csatib02.

The following was tested on the same project with the same configuration in .golangci.yml

Both tests executed using with v1.59.1 of golangci-lint.

$ go version
go version go1.22.6 linux/amd64

$ golangci-lint run --config .golangci.yml -v
INFO golangci-lint has version v1.59.1 built with go1.22.3 from (unknown, modified: ?, mod sum: "h1:CRRLu1JbhK5avLABFJ/OHVSQ0Ie5c4ulsOId1h3TTks=") on (unknown)
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 15 linters: [dupl errcheck goconst gocyclo gofmt goimports gosimple govet ineffassign lll nakedret revive staticcheck unparam unused]
INFO [loader] Go packages loading at mode 575 (compiled_files|exports_file|files|types_sizes|deps|imports|name) took 25.154011554s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 3.87889ms
INFO [linters_context/goanalysis] analyzers took 36.756887911s with top 10 stages: buildir: 24.902759377s, the_only_name: 2.22069428s, inspect: 1.265404249s, fact_deprecated: 1.147784383s, ctrlflow: 965.664364ms, printf: 933.598201ms, fact_purity: 840.371699ms, nilness: 717.932495ms, typedness: 697.868938ms, SA5012: 504.593487ms
INFO [runner] Issues before processing: 18, after processing: 0
INFO [runner] Processors filtering stat (out/in): skip_dirs: 18/18, cgo: 18/18, path_prettifier: 18/18, autogenerated_exclude: 18/18, exclude: 18/18, identifier_marker: 18/18, exclude-rules: 4/18, nolint: 0/4, filename_unadjuster: 18/18, skip_files: 18/18, invalid_issue: 18/18
INFO [runner] processing took 5.673253ms with stages: nolint: 4.565837ms, exclude-rules: 266.95µs, path_prettifier: 265.448µs, autogenerated_exclude: 258.232µs, identifier_marker: 238.386µs, skip_dirs: 51.066µs, cgo: 16.581µs, max_same_issues: 2.235µs, invalid_issue: 2.164µs, filename_unadjuster: 1.684µs, uniq_by_line: 1.273µs, fixer: 702ns, diff: 531ns, exclude: 461ns, source_code: 461ns, skip_files: 321ns, sort_results: 280ns, max_from_linter: 241ns, max_per_file_from_linter: 140ns, path_shortener: 90ns, path_prefixer: 90ns, severity-rules: 80ns
INFO [runner] linters took 7.609912344s with stages: goanalysis_metalinter: 7.604065889s
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 329 samples, avg is 148.5MB, max is 823.0MB
INFO Execution took 32.786907868s
$ go version
go version go1.23.0 linux/amd64

$ golangci-lint run --config .golangci.yml -v
INFO golangci-lint has version v1.59.1 built with go1.23.0 from (unknown, modified: ?, mod sum: "h1:CRRLu1JbhK5avLABFJ/OHVSQ0Ie5c4ulsOId1h3TTks=") on (unknown)
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 15 linters: [dupl errcheck goconst gocyclo gofmt goimports gosimple govet ineffassign lll nakedret revive staticcheck unparam unused]
INFO [loader] Go packages loading at mode 575 (imports|exports_file|deps|files|name|types_sizes|compiled_files) took 393.545963ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 4.620283ms
Killed

EDIT: After running more tests, as soon as you update the golangci-lint version to v1.60.1 or later the problem is solved when using go v1.23.0

ldez commented 2 months ago

Related to #4837

Duplicate of #4909, #4908, #4932