Skip to content

Panic when running contextcheck #5480

Closed
@palsivertsen

Description

@palsivertsen

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?

AUR

Description of the problem

First off, apologies if this is an issue with the contextcheck and not golangci-lint.

I get the following panic when running golangci-lint with contextcheck:

ERRO [runner] Panic: contextcheck: package "main" (isInitialPkg: true, needAnalyzeSource: true): unreachable: goroutine 385 [running]:

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.64.5 built with go1.24.0 from 0a603e49 on 2025-02-13T21:19:55Z

Configuration

-no-config --disable-all --enable contextcheck

Go environment

$ go version && go env
go version go1.24.0 linux/amd64
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/pal/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/pal/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1505087625=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/tmp/tmp.sSLzfc5dYn/go.mod'
GOMODCACHE='/home/pal/go/pkg/mod'
GONOPROXY='REDACTED'
GONOSUMDB='REDACTED'
GOOS='linux'
GOPATH='/home/pal/go'
GOPRIVATE='REDACTED'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/pal/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v --no-config --disable-all --enable contextcheck main.go
INFO golangci-lint has version 1.64.5 built with go1.24.0 from 0a603e49 on 2025-02-13T21:19:55Z 
INFO [goenv] Read go env for 3.442715ms: map[string]string{"GOCACHE":"/home/pal/.cache/go-build", "GOROOT":"/usr/lib/go"} 
INFO [lintersdb] Active 1 linters: [contextcheck] 
INFO [loader] Go packages loading at mode 8767 (name|compiled_files|files|types_sizes|deps|exports_file|imports) took 60.596234ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 112.958µs 
INFO [linters_context/goanalysis] analyzers took 178.142403ms with top 10 stages: buildssa: 171.928575ms, contextcheck: 6.209283ms, typecheck: 4.545µs 
ERRO [runner] Panic: contextcheck: package "main" (isInitialPkg: true, needAnalyzeSource: true): unreachable: goroutine 379 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe.func1()
	github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:50 +0x257
panic({0x123e7a0?, 0x172a0b0?})
	runtime/panic.go:787 +0x132
go/types.(*comparer).identical(0xc00193d71c, {0x173ad88?, 0x2154420?}, {0x17397b8?, 0xc0018a85b0?}, 0x0)
	go/types/predicates.go:499 +0x998
go/types.(*comparer).identical(0xc00197171c, {0x17398d0?, 0x2154410?}, {0x17398d0?, 0xc00252c820?}, 0x0)
	go/types/predicates.go:313 +0x57f
go/types.Identical(...)
	go/types/api_predicates.go:90
github.com/kkHAIKE/contextcheck.(*runner).isCtxType(0xc001b2c660, {0x17398d0, 0x2154410})
	github.com/kkHAIKE/contextcheck@v1.1.5/contextcheck.go:730 +0x79
github.com/kkHAIKE/contextcheck.(*runner).getCallInstrCtxType(0xc001b2c660, {0x72ed4089eeb0, 0xc001b12400})
	github.com/kkHAIKE/contextcheck@v1.1.5/contextcheck.go:669 +0xfc
github.com/kkHAIKE/contextcheck.(*runner).getCtxType(0xc001b2c660?, {0x1746578?, 0xc001b12400?})
	github.com/kkHAIKE/contextcheck@v1.1.5/contextcheck.go:643 +0xc5
github.com/kkHAIKE/contextcheck.(*runner).checkFuncWithoutCtx(0xc001b2c660, 0xc001b26e00, 0xc00193db20)
	github.com/kkHAIKE/contextcheck@v1.1.5/contextcheck.go:572 +0x13b
github.com/kkHAIKE/contextcheck.(*runner).run(0xc001b2c660, 0xc0025b4620)
	github.com/kkHAIKE/contextcheck@v1.1.5/contextcheck.go:173 +0x4c5
github.com/kkHAIKE/contextcheck.NewRun.func1(0xc0025b4620)
	github.com/kkHAIKE/contextcheck@v1.1.5/contextcheck.go:131 +0xf9
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze.func3(...)
	github.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:182
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze(0xc001f40008)
	github.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:208 +0xb62
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc0019ce7d0, {0x14af4e6, 0xc}, 0xc000f26f48)
	github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe(0xc00005c9c0?)
	github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:54 +0x71
github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze.func2(0xc001f40008)
	github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:83 +0xa5
created by github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze in goroutine 202
	github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:78 +0x1e9 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: contextcheck: package "main" (isInitialPkg: true, needAnalyzeSource: true): unreachable 
INFO [runner] processing took 2.422µs with stages: max_same_issues: 309ns, exclusion_paths: 203ns, path_absoluter: 186ns, skip_dirs: 178ns, exclusion_rules: 162ns, nolint_filter: 161ns, skip_files: 151ns, generated_file_filter: 100ns, sort_results: 96ns, diff: 96ns, max_per_file_from_linter: 93ns, filename_unadjuster: 93ns, source_code: 91ns, path_relativity: 88ns, max_from_linter: 81ns, path_prettifier: 61ns, cgo: 43ns, fixer: 42ns, invalid_issue: 41ns, path_shortener: 40ns, uniq_by_line: 36ns, severity-rules: 36ns, identifier_marker: 35ns 
INFO [runner] linters took 428.036783ms with stages: goanalysis_metalinter: 428.000257ms 
ERRO Running error: can't run linter goanalysis_metalinter
goanalysis_metalinter: contextcheck: package "main" (isInitialPkg: true, needAnalyzeSource: true): unreachable 
INFO Memory: 6 samples, avg is 88.0MB, max is 137.7MB 
INFO Execution took 492.711172ms

A minimal reproducible example or link to a public repository

package main

import (
	"context"
	"iter"
)

func main() {
	var iter iter.Seq[any]
	for range iter {
		_, cancel := context.WithCancel(context.Background())
		defer cancel()
	}
}

Validation

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

Supporter

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdependenciesRelates to an upstream dependency

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions