Skip to content

staticcheck uses too much memory and crashes #4932

@tang-fh

Description

@tang-fh

Welcome

  • Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've read the typecheck section of the FAQ.
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
  • I agree to follow this project's Code of Conduct

Description of the problem

golangci-lint uses too much memory (and is killed) when running against the sources from https://github.com/prometheus/blackbox_exporter/

I have narrowed it down to the staticcheck linter.

Workarounds I have found:

Version of golangci-lint

$ ~/go/bin/golangci-lint --version
golangci-lint has version 1.56.2 built with go1.22.0 from 58a724a0 on 2024-02-15T18:01:51Z

Configuration

$ cat .golangci.yml 
# Run only staticcheck for now. Additional linters will be enabled one-by-one.
linters:
  disable-all: true
  enable:
    - misspell
    - staticcheck

Go environment

$ go version && go env
go version go1.23.0 linux/amd64
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/fhltang/.cache/go-build'
GOENV='/home/fhltang/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/fhltang/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/fhltang/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go1.23.0'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go1.23.0/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/fhltang/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/fhltang/blackbox_exporter/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 -ffile-prefix-map=/tmp/go-build2371056276=/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/fhltang/blackbox_exporter /home/fhltang /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 2 linters: [misspell staticcheck] 
INFO [loader] Go packages loading at mode 575 (files|imports|types_sizes|deps|exports_file|name|compiled_files) took 984.22745ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 4.722143ms 
INFO Memory: 415 samples, avg is 13735.1MB, max is 27340.7MB 
INFO Execution took 1m0.225270189s                
Killed

A minimal reproducible example or link to a public repository

$ git clone https://github.com/prometheus/blackbox_exporter.git
$ make
>> checking code style
>> checking license header
mkdir -p /home/fhltang/go/bin
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/v1.56.2/install.sh \
        | sed -e '/install -d/d' \
        | sh -s -- -b /home/fhltang/go/bin v1.56.2
golangci/golangci-lint info checking GitHub for tag 'v1.56.2'
golangci/golangci-lint info found version: 1.56.2 for v1.56.2/linux/amd64
golangci/golangci-lint info installed /home/fhltang/go/bin/golangci-lint
>> running golangci-lint
/home/fhltang/go/bin/golangci-lint run  ./...
make: *** [Makefile.common:172: common-lint] Killed

Validation

  • Yes, I've included all information above (version, config, etc.).

Supporter

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already existsquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions