Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks done
SLoeuillet opened this issue Apr 2, 2024 · 4 comments
Closed
5 tasks done

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

SLoeuillet opened this issue Apr 2, 2024 · 4 comments
Labels
bug Something isn't working dependencies Relates to an upstream dependency

Comments

@SLoeuillet
Copy link

SLoeuillet commented Apr 2, 2024

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/[email protected]/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/[email protected]/intrange.go:237 +0x13a
github.com/ckaznocha/intrange.run.check.func1({0x1c10770?, 0xc002000c00})
	/home/sloeuillet/go/pkg/mod/github.com/ckaznocha/[email protected]/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/[email protected]/go/ast/inspector/inspector.go:82 +0x8f
github.com/ckaznocha/intrange.run(0xc00449b2b0)
	/home/sloeuillet/go/pkg/mod/github.com/ckaznocha/[email protected]/intrange.go:47 +0x129
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze(0xc002fdc1c0)
	/home/sloeuillet/go/pkg/mod/github.com/golangci/[email protected]/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/[email protected]/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/[email protected]/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe(0x404040404030303?)
	/home/sloeuillet/go/pkg/mod/github.com/golangci/[email protected]/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/[email protected]/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/[email protected]/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.).
@SLoeuillet SLoeuillet added the bug Something isn't working label Apr 2, 2024
Copy link

boring-cyborg bot commented Apr 2, 2024

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

@SLoeuillet SLoeuillet changed the title 1.57.2 - crash with intrange on identified code (where 1.57.1 didn't) 1.57.2 - crash with intrange (where 1.57.1 didn't) Apr 2, 2024
@SLoeuillet
Copy link
Author

I suppose it is fixed by https://github.com/ckaznocha/intrange/releases/tag/v0.1.2
golangci-lint 1.57.2 includes bump to v0.1.1

@SLoeuillet
Copy link
Author

Confirmed to be fixed with commit that bumps to intrange v0.1.2 :
go install github.com/golangci/golangci-lint/cmd/golangci-lint@4e56cba3a8b7e8befbfd562dcc2e2159d98fef5c

tools/db/bind.go:49:3: for loop can be changed to use an integer range (Go 1.22+) (intrange)
		for i := 0; i < v.Len(); i++ {
		^

@ldez ldez added the dependencies Relates to an upstream dependency label Apr 2, 2024
@ldez
Copy link
Member

ldez commented Apr 2, 2024

fixed by #4601

@ldez ldez closed this as completed Apr 2, 2024
@ldez ldez changed the title 1.57.2 - crash with intrange (where 1.57.1 didn't) intrange: crash with 1.57.2 (where 1.57.1 didn't) Apr 2, 2024
Gearheads added a commit to fidelity/kconnect that referenced this issue May 1, 2024
…settings, and fix lint errors

This change will downgrade the version of golangci-lint to 1.57.1, because there is currently a bug within 1.57.2 mentioned here golangci/golangci-lint#4606

Signed-off-by: Casale, Robert <[email protected]>
Gearheads added a commit to fidelity/kconnect that referenced this issue May 1, 2024
…settings, and fix lint errors

This change will downgrade the version of golangci-lint to 1.57.1, because there is currently a bug within 1.57.2 mentioned here golangci/golangci-lint#4606

Signed-off-by: Casale, Robert <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Relates to an upstream dependency
Projects
None yet
Development

No branches or pull requests

2 participants