Skip to content
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

Invalid line number panic #5278

Closed
6 of 7 tasks
remyleone opened this issue Jan 2, 2025 · 9 comments · Fixed by #5279
Closed
6 of 7 tasks

Invalid line number panic #5278

remyleone opened this issue Jan 2, 2025 · 9 comments · Fixed by #5279
Assignees
Labels
bug Something isn't working

Comments

@remyleone
Copy link

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

I would expect golangci-lint to not crash. Maybe sending errors but not panic

Version of golangci-lint

$ golangci-lint --version         
golangci-lint has version 1.63.1 built with go1.23.4 from 2980928 on 2025-01-01T18:03:10Z

Configuration

# paste configuration file or CLI flags here

Go environment

$ go version && go env
go version go1.23.4 darwin/arm64
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/rleone/Library/Caches/go-build'
GOENV='/Users/rleone/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/rleone/go/pkg/mod'
GONOPROXY='gitlab.infra.online.net'
GONOSUMDB='gitlab.infra.online.net'
GOOS='darwin'
GOPATH='/Users/rleone/go'
GOPRIVATE='gitlab.infra.online.net'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.4/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.4/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/rleone/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'

Verbose output of running

$ golangci-lint run -v ./...
INFO golangci-lint has version 1.63.1 built with go1.23.4 from 2980928 on 2025-01-01T18:03:10Z 
INFO [config_reader] Config search paths: [./ /Users/rleone/workspace/scaleway-cli /Users/rleone/workspace /Users/rleone /Users /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 65 linters: [asasalint asciicheck bidichk bodyclose canonicalheader copyloopvar decorder dogsled durationcheck errcheck errchkjson errname gci gocheckcompilerdirectives gochecksumtype goconst gocritic gocyclo gofmt gofumpt goheader goimports gomoddirectives gomodguard goprintffuncname gosec gosimple govet grouper importas ineffassign intrange loggercheck makezero mirror misspell musttag nakedret nilerr nolintlint nosprintfhostport perfsprint prealloc predeclared promlinter protogetter reassign revive rowserrcheck sloglint staticcheck stylecheck tagalign tenv testifylint testpackage thelper tparallel unconvert unparam unused usestdlibvars wastedassign whitespace zerologlint] 
INFO [loader] Go packages loading at mode 8767 (files|imports|compiled_files|exports_file|types_sizes|deps|name) took 1.514919542s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 25.430875ms 
INFO [linters_context] importas settings found, but no aliases listed. List aliases under alias: key. 
INFO [linters_context/goanalysis] analyzers took 13m32.210503866s with top 10 stages: goimports: 51.191925416s, the_only_name: 41.775244708s, buildir: 26.400249288s, wastedassign: 19.520291168s, unconvert: 14.01887117s, musttag: 12.477721745s, unparam: 10.400576958s, gosec: 9.99347108s, gofmt: 9.615261545s, gocritic: 8.987533914s 
ERRO [runner] Panic: gofumpt: package "account" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 225 (should be < 223): goroutine 35617 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:26 +0x64
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe.func1()
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:50 +0x21c
panic({0x101781b20?, 0x1400975c550?})
        runtime/panic.go:785 +0x124
go/token.(*File).LineStart(0x1401cc6bac0?, 0x140176dd5d0?)
        go/token/position.go:232 +0x178
github.com/golangci/golangci-lint/pkg/goanalysis.EndOfLinePos(0x1401cc6baa0, 0xe0)
        github.com/golangci/golangci-lint/pkg/goanalysis/position.go:44 +0x58
github.com/golangci/golangci-lint/pkg/golinters/internal.toDiagnostic(0x1401cc6baa0, {0xdc, 0xe0, {0x1400ee06880, 0x4, 0x4}}, 0x0)
        github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go:256 +0x74
github.com/golangci/golangci-lint/pkg/golinters/internal.ExtractDiagnosticFromPatch(0x1400376c620, 0x14014d06c80, {0x1401097ec00, 0x396}, 0x140000b1740)
        github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go:245 +0x334
github.com/golangci/golangci-lint/pkg/golinters/gofumpt.runGofumpt(0x140000b1740, 0x1400376c620, {0x1019d3500, 0x1025998c8}, {{0x14000f13220, 0x8}, {0x0, 0x0}, 0x0})
        github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go:89 +0x324
github.com/golangci/golangci-lint/pkg/golinters/gofumpt.New.func1.1(0x10000000000?)
        github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go:52 +0x48
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze.func3(0x14004dd4a00, 0x1400376c620)
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:182 +0xd0
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze(0x14004dd4a00)
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:208 +0x97c
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0x14002a2be50, {0x1013caef5, 0x7}, 0x14002daff30)
        github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe(0x100d28cf0?)
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:54 +0x70
github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze.func2(0x14004dd4a00)
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:83 +0xac
created by github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze in goroutine 1097
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:78 +0x174 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: gofumpt: package "account" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 225 (should be < 223) 
INFO [runner] processing took 1.705µs with stages: max_same_issues: 458ns, skip_dirs: 208ns, filename_unadjuster: 167ns, cgo: 167ns, path_prettifier: 125ns, max_per_file_from_linter: 83ns, path_shortener: 42ns, severity-rules: 42ns, autogenerated_exclude: 42ns, nolint: 42ns, invalid_issue: 42ns, path_prefixer: 41ns, sort_results: 41ns, max_from_linter: 41ns, fixer: 41ns, skip_files: 41ns, uniq_by_line: 41ns, diff: 41ns, exclude: 0s, exclude-rules: 0s, identifier_marker: 0s, source_code: 0s 
INFO [runner] linters took 13.926692958s with stages: goanalysis_metalinter: 13.92600125s 
ERRO Running error: can't run linter goanalysis_metalinter
goanalysis_metalinter: gofumpt: package "account" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 225 (should be < 223) 
INFO Memory: 156 samples, avg is 563.9MB, max is 1011.6MB 
INFO Execution took 15.4908795s                   
(

A minimal reproducible example or link to a public repository

https://github.com/scaleway/scaleway-cli
You should reproduce with this commit scaleway/scaleway-cli@d03f829

Validation

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

Supporter

@remyleone remyleone added the bug Something isn't working label Jan 2, 2025
@ldez ldez self-assigned this Jan 2, 2025
@rbrady98
Copy link

rbrady98 commented Jan 2, 2025

Also experiencing this in CI against version 1.63.1, same metalinter error just with a different linter. Tested with 1.62.2 and not getting the error locally

@ldez
Copy link
Member

ldez commented Jan 2, 2025

If you are facing the same problem, the best way to contribute is to provide the following information:

A code example or link to a public repository.

golangci-lint --version
cat .golangci.yml
go version && go env
golangci-lint cache clean
golangci-lint run -v

@ldez
Copy link
Member

ldez commented Jan 2, 2025

FYI, I'm on the topic

@ldez ldez changed the title gofumpt panic panic when missing EOL Jan 2, 2025
@ldez
Copy link
Member

ldez commented Jan 2, 2025

I created a fix.

The problem happens when a file has no EOL on the last line of the file.
The workaround is to add the missing EOL.

@ldez ldez changed the title panic when missing EOL panic invalid line number Jan 2, 2025
@ldez ldez changed the title panic invalid line number Invalid line number panic Jan 2, 2025
@ldez ldez closed this as completed in #5279 Jan 2, 2025
@ldez
Copy link
Member

ldez commented Jan 2, 2025

Fixed in v1.63.2

@yurishkuro
Copy link

We're still getting the same error with v1.63.2

The workaround is to add the missing EOL.

The output doesn't specify which file is causing the panic. I've seen it fail complaining about different packages.

@ldez
Copy link
Member

ldez commented Jan 2, 2025

level=info msg="golangci-lint has version v1.63.2 built with go1.23.4 from (unknown, modified: ?, mod sum: "h1:igdU9duGfb/TiON2SRuNh0SXK0qtx72jjApj1NbaJso=") on (unknown)"
level=info msg="[config_reader] Config search paths: [./ /home/runner/work/jaeger/jaeger /home/runner/work/jaeger /home/runner/work /home/runner /home /]"

Can you try v1.63.3?

@yurishkuro
Copy link

Thanks - v1.63.3 worked (renovate bot just updated the PR).

@ldez
Copy link
Member

ldez commented Jan 2, 2025

So your problem was related to #5285

The problem was related to the following files:

./thrift-gen/zipkincore/GoUnusedProtection__.go
./thrift-gen/zipkincore/zipkincore-consts.go
./thrift-gen/sampling/GoUnusedProtection__.go
./thrift-gen/sampling/sampling-consts.go
./thrift-gen/baggage/GoUnusedProtection__.go
./thrift-gen/baggage/baggage-consts.go
./thrift-gen/jaeger/GoUnusedProtection__.go
./thrift-gen/jaeger/jaeger-consts.go
./thrift-gen/agent/GoUnusedProtection__.go
./thrift-gen/agent/agent-consts.go

Because they contain 2 empty lines at the end of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants