Skip to content

intrange: crash with 1.57.2 (where 1.57.1 didn't) #4606

Closed
@SLoeuillet

Description

@SLoeuillet

Welcome

Description of the problem

golangci-lint run crashes with 1.57.2 where it didn't crash with 1.57.1, on intrange check

Version of golangci-lint

golangci-lint has version v1.57.2 built with go1.22.0 from (unknown, modified: ?, mod sum: "h1:NNhxfZyL5He1WWDrIvl1a4n5bvWZBcgAqBwlJAAgLTw=") on (unknown)

Configuration

---
issues:
  exclude-dirs:
    - kli
    - observability/metric
  exclude-rules:
    
    - path: "bin/[a-z]+/main\\.go"
      linters:
        - dupl
    - path: ".*_test.go"
      linters:
        - dupl
        - goerr113
        - maintidx
  exclude-use-default: false
  max-per-linter: 0
  max-same-issues: 0

linters:
  disable:
    - deadcode 
    - exhaustivestruct 
    - golint  
    - ifshort 
    - interfacer 
    - maligned  
    - nosnakecase 
    - scopelint 
    - structcheck 
    - varcheck 

    - cyclop  
    - containedctx  
    - depguard 
    - exhaustruct
    - forcetypeassert  
    - funlen  
    - gomnd  
    - gomoddirectives  
    - ireturn  
    - lll  
    - nilnil  
    - nolintlint  
    - nonamedreturns
    - sqlclosecheck  
    - tagalign 
    - thelper  
    - varnamelen  
    - wrapcheck  

  enable-all: true

linters-settings:
  tagliatelle:
    case:
      use-field-name: true
      rules:
        json: snake
  gosec:
    excludes:
      - G112  

output:
  format: colored-line-number
  print-issued-lines: true
  print-linter-name: true

run:
  timeout: 10m
  issues-exit-code: 1
  skip-dirs:
    - kli
    - observability/metric
  tests: true
  allow-parallel-runners: true

Go environment

go version go1.22.0 linux/amd64
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/sloeuillet/.cache/go-build'
GOENV='/home/sloeuillet/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/sloeuillet/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/sloeuillet/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/sloeuillet/Documents/Kaiko/github/pkg/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-build3036735910=/tmp/go-build -gno-record-gcc-switches'

Verbose output of running

INFO [config_reader] Config search paths: [./ /home/sloeuillet/Documents/Kaiko/github/pkg/tools/db /home/sloeuillet/Documents/Kaiko/github/pkg/tools /home/sloeuillet/Documents/Kaiko/github/pkg /home/sloeuillet/Documents/Kaiko/github /home/sloeuillet/Documents/Kaiko /home/sloeuillet/Documents /home/sloeuillet /home /] 
INFO [config_reader] Used config file .golangci.yml 
WARN [config_reader] The configuration option `run.skip-dirs` is deprecated, please use `issues.exclude-dirs`. 
WARN [config_reader] The configuration option `output.format` is deprecated, please use `output.formats` 
INFO [lintersdb] Active 87 linters: [asasalint asciicheck bidichk bodyclose contextcheck copyloopvar decorder dogsled dupl dupword durationcheck errcheck errchkjson errname errorlint execinquery exhaustive exportloopref forbidigo gci ginkgolinter gocheckcompilerdirectives gochecknoglobals gochecknoinits gochecksumtype gocognit goconst gocritic gocyclo godot godox goerr113 gofmt gofumpt goheader goimports gomodguard goprintffuncname gosec gosimple gosmopolitan govet grouper importas inamedparam ineffassign interfacebloat intrange loggercheck maintidx makezero mirror misspell musttag nakedret nestif nilerr nlreturn noctx nosprintfhostport paralleltest perfsprint prealloc predeclared promlinter protogetter reassign revive rowserrcheck sloglint spancheck staticcheck stylecheck tagliatelle tenv testableexamples testifylint testpackage tparallel unconvert unparam unused usestdlibvars wastedassign whitespace wsl zerologlint] 
INFO [loader] Go packages loading at mode 575 (deps|name|types_sizes|compiled_files|exports_file|files|imports) took 118.985006ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 950.609µs 
INFO [linters_context] importas settings found, but no aliases listed. List aliases under alias: key. 
INFO [linters_context/goanalysis] analyzers took 3.275905985s with top 10 stages: buildir: 1.44389201s, buildssa: 580.343495ms, the_only_name: 473.780672ms, exhaustive: 228.939257ms, inspect: 70.138656ms, ctrlflow: 62.202525ms, printf: 59.800116ms, nilness: 52.46337ms, SA5012: 51.200701ms, fact_purity: 47.221915ms 
ERRO [runner] Panic: intrange: package "db" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident: goroutine 1894 [running]:
runtime/debug.Stack()
	/opt/go/src/runtime/debug/stack.go:24 +0x5e
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe.func1()
	/home/sloeuillet/go/pkg/mod/github.com/golangci/golangci-lint@v1.57.2/pkg/goanalysis/runner_action.go:108 +0x277
panic({0x17db040?, 0xc0042680c0?})
	/opt/go/src/runtime/panic.go:770 +0x132
github.com/ckaznocha/intrange.findNExpr({0x1c149b8?, 0xc002000a80?})
	/home/sloeuillet/go/pkg/mod/github.com/ckaznocha/intrange@v0.1.1/intrange.go:237 +0x13a
github.com/ckaznocha/intrange.run.check.func1({0x1c10770?, 0xc002000c00})
	/home/sloeuillet/go/pkg/mod/github.com/ckaznocha/intrange@v0.1.1/intrange.go:95 +0x1f4
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0xc007d1c138, {0xc00466cca8?, 0x24d3040?, 0xc002106ea0?}, 0xc002641c98)
	/home/sloeuillet/go/pkg/mod/golang.org/x/tools@v0.19.0/go/ast/inspector/inspector.go:82 +0x8f
github.com/ckaznocha/intrange.run(0xc00449b2b0)
	/home/sloeuillet/go/pkg/mod/github.com/ckaznocha/intrange@v0.1.1/intrange.go:47 +0x129
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze(0xc002fdc1c0)
	/home/sloeuillet/go/pkg/mod/github.com/golangci/golangci-lint@v1.57.2/pkg/goanalysis/runner_action.go:190 +0xa02
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe.func2()
	/home/sloeuillet/go/pkg/mod/github.com/golangci/golangci-lint@v1.57.2/pkg/goanalysis/runner_action.go:112 +0x17
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc00211d4a0, {0x1953344, 0x8}, 0xc00466cf48)
	/home/sloeuillet/go/pkg/mod/github.com/golangci/golangci-lint@v1.57.2/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe(0x404040404030303?)
	/home/sloeuillet/go/pkg/mod/github.com/golangci/golangci-lint@v1.57.2/pkg/goanalysis/runner_action.go:111 +0x7a
github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze.func2(0xc002fdc1c0)
	/home/sloeuillet/go/pkg/mod/github.com/golangci/golangci-lint@v1.57.2/pkg/goanalysis/runner_loadingpackage.go:80 +0xa8
created by github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze in goroutine 317
	/home/sloeuillet/go/pkg/mod/github.com/golangci/golangci-lint@v1.57.2/pkg/goanalysis/runner_loadingpackage.go:75 +0x205 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: intrange: package "db" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident 
INFO [runner] processing took 35.756µs with stages: max_from_linter: 2.444µs, max_same_issues: 2.444µs, path_prefixer: 1.955µs, skip_dirs: 1.886µs, sort_results: 1.886µs, source_code: 1.886µs, path_shortener: 1.886µs, diff: 1.815µs, severity-rules: 1.467µs, nolint: 1.467µs, invalid_issue: 1.467µs, path_prettifier: 1.467µs, skip_files: 1.466µs, filename_unadjuster: 1.466µs, cgo: 1.397µs, max_per_file_from_linter: 1.397µs, exclude: 1.397µs, uniq_by_line: 1.397µs, autogenerated_exclude: 1.397µs, identifier_marker: 1.396µs, fixer: 1.396µs, exclude-rules: 977ns 
INFO [runner] linters took 2.407116657s with stages: goanalysis_metalinter: 2.406954346s 
ERRO Running error: can't run linter goanalysis_metalinter
goanalysis_metalinter: intrange: package "db" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident 
INFO Memory: 27 samples, avg is 187.5MB, max is 286.3MB 
INFO Execution took 2.533108697s             

A minimal reproducible example or link to a public repository

		values := make([]string, 0, v.Len())
		for i := 0; i < v.Len(); i++ {
			values = append(values, quote(v.Index(i).Interface()))
		}

Validation

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

Metadata

Metadata

Assignees

No one assigned

    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