Skip to content

"panic: close of closed channel" in v2.2.1 #5923

@leonklingele

Description

@leonklingele

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

How did you install golangci-lint?

Nix

Description of the problem

golangci-lint v2.2.1 just panicked for me on my https://github.com/leonklingele/lmk repo. I couldn't reproduce the panic, so it's probably a data race.

Steps to reproduce, including the config files & specific version of the binaries used:

$ git clone --depth 1 https://github.com/leonklingele/lmk
$ cd lmk
$ git checkout d2e28797d45b1c7a290dd3079c054a2568b74f37
$ nix-shell # or direnv allow

# Apply the following patch:
diff --git a/main.go b/main.go
index 1e99350ac0db92349d3c565428dee2cc4187f170..5116a696ada57f032c80a6ef3c8e6ba54c7bd11a 100644
--- a/main.go
+++ b/main.go
@@ -427 +427 @@ func main() {
-    ctx := context.Background()
+    ctx = context.Background()

$ OUT="" ; until [[ "$OUT" == *"panic"* ]]; do OUT="$(make lint 2>&1)" ; done ; echo "$OUT"
INFO golangci-lint has version 2.2.1 built with go1.24.4 from v2.2.1 on 19700101-00:00:00
INFO [config_reader] Config search paths: [./ /Users/leon/code/lmk /Users/leon/code /Users/leon /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [config_reader] Module name "github.com/leonklingele/lmk"
INFO maxprocs: Leaving GOMAXPROCS=14: CPU quota undefined
INFO [goenv] Read go env for 4.600167ms: map[string]string{"GOCACHE":"/Users/leon/code/lmk/.gopath/.cache", "GOROOT":"/nix/store/rq7irijkj3nhapmjcv9d96xgkisj55x2-go-1.24.4/share/go"}
INFO [lintersdb] Active 89 linters: [asasalint asciicheck bidichk bodyclose canonicalheader containedctx contextcheck copyloopvar decorder depguard dogsled dupword durationcheck embeddedstructfieldcheck err113 errcheck errchkjson errname errorlint exhaustive exptostd fatcontext forbidigo forcetypeassert funcorder gci ginkgolinter gocheckcompilerdirectives gochecknoglobals gochecknoinits gochecksumtype goconst gocritic gofmt gofumpt goimports gomoddirectives goprintffuncname gosec gosmopolitan govet grouper iface ineffassign intrange loggercheck makezero mirror misspell mnd musttag nakedret nestif nilerr nilnesserr nilnil noctx nolintlint nonamedreturns nosprintfhostport paralleltest perfsprint predeclared promlinter protogetter reassign recvcheck revive rowserrcheck sloglint spancheck sqlclosecheck staticcheck tagalign tagliatelle testableexamples testifylint testpackage thelper tparallel unconvert unparam unused usestdlibvars usetesting wastedassign whitespace wrapcheck zerologlint]
INFO [loader] Go packages loading at mode 8767 (types_sizes|exports_file|imports|name|compiled_files|deps|files) took 192.021375ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 371.959µs
panic: close of closed channel

goroutine 5508 [running]:
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*loadingPackage).analyze.func2(0x14003e2da80)
	github.com/golangci/golangci-lint/v2/pkg/goanalysis/runner_loadingpackage.go:109 +0x11c
created by github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*loadingPackage).analyze in goroutine 786
	github.com/golangci/golangci-lint/v2/pkg/goanalysis/runner_loadingpackage.go:91 +0x174
make: *** [Makefile:14: lint] Error 2

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 2.2.1 built with go1.24.4 from v2.2.1 on 19700101-00:00:00

Configuration

See https://github.com/leonklingele/lmk/blob/d2e28797d45b1c7a290dd3079c054a2568b74f37/.golangci.yml

Go environment

$ go version && go env
# paste output here

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# See above, not reproducible

A minimal reproducible example or link to a public repository

See above

Validation

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

Supporter

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions