Skip to content
New issue

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

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

Already on GitHub? # to your account

unexpected lint panic error in newest version v1.63.0 #5271

Closed
6 of 7 tasks
oowl opened this issue Jan 1, 2025 · 5 comments · Fixed by #5272
Closed
6 of 7 tasks

unexpected lint panic error in newest version v1.63.0 #5271

oowl opened this issue Jan 1, 2025 · 5 comments · Fixed by #5272
Assignees
Labels
area: auto-fix area: cgo Related to CGO or line directives bug Something isn't working

Comments

@oowl
Copy link

oowl commented Jan 1, 2025

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

When I upgraded golangci-lint to the latest version, the following unexpected error occurred. suppose I downgrade it to v1.62.x version, the error message was gone as expected.

Running [/home/runner/golangci-lint-1.63.0-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
  level=warning msg="[config_reader] The configuration option `run.skip-dirs-use-default` is deprecated, please use `issues.exclude-dirs-use-default`."
  level=warning msg="[config_reader] The output format `github-actions` is deprecated, please use `colored-line-number`"
  level=error msg="[runner] Panic: gofumpt: package \"process\" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 36 (should be < 35): goroutine 17173 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.heygears.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe.func1()\n\tgithub.heygears.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:50 +0x277\npanic({0x11c1640?, 0xc006894790?})\n\truntime/panic.go:785 +0x132\ngo/token.(*File).LineStart(0x1?, 0xc0076270e0?)\n\tgo/token/position.go:232 +0x168\ngithub.heygears.com/golangci/golangci-lint/pkg/golinters/internal.toDiagnostic(0xc0099f9aa0, {0x24, 0x24, {0x0, 0x0, 0x0}}, 0x0)\n\tgithub.heygears.com/golangci/golangci-lint/pkg/golinters/internal/diff.go:254 +0x85\ngithub.heygears.com/golangci/golangci-lint/pkg/golinters/internal.ExtractDiagnosticFromPatch(0xc00f07d500, 0xc00afdf400, {0xc00760d880, 0x[30](https://github.com/cyberandao/headless-client/actions/runs/12571592487/job/35042738137#step:7:32)9}, 0xc00050e660)\n\tgithub.heygears.com/golangci/golangci-lint/pkg/golinters/internal/diff.go:245 +0x4a5\ngithub.heygears.com/golangci/golangci-lint/pkg/golinters/gofumpt.runGofumpt(0xc00050e660, 0xc00f07d500, {0x16926e0, 0x21b8740}, {{0xc000e6abf0, 0x8}, {0x0, 0x0}, 0x0})\n\tgithub.heygears.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go:86 +0x449\ngithub.heygears.com/golangci/golangci-lint/pkg/golinters/gofumpt.New.func1.1(0x4600000000?)\n\tgithub.heygears.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go:52 +0x3d\ngithub.heygears.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze.func3(0xc004fe7880, 0xc00f07d500)\n\tgithub.heygears.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:182 +0xeb\ngithub.heygears.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze(0xc004fe7880)\n\tgithub.heygears.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:208 +0xa9c\ngithub.heygears.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc001faf090, {0x13b98e0, 0x7}, 0xc003abdf48)\n\tgithub.heygears.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x44\ngithub.heygears.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe(0xc002bdec60?)\n\tgithub.heygears.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:54 +0x71\ngithub.heygears.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze.func2(0xc004fe7880)\n\tgithub.heygears.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:83 +0xa5\ncreated by github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze in goroutine 890\n\tgithub.heygears.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:78 +0x1e9\n"
  level=warning msg="[runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: gofumpt: package \"process\" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 36 (should be < 35)"
  level=error msg="Running error: can't run linter goanalysis_metalinter\ngoanalysis_metalinter: gofumpt: package \"process\" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 36 (should be < 35)"

Version of golangci-lint

$ golangci-lint --version
# Paste output here

Configuration

# paste configuration file or CLI flags here
golangci-lint run --fix

Go environment

$ go version && go env
# paste output here
go version go1.23.4 linux/amd64
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/vagrant/.cache/go-build'
GOENV='/home/vagrant/.config/go/env'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
WARN [config_reader] The configuration option `run.skip-dirs-use-default` is deprecated, please use `issues.exclude-dirs-use-default`. 
ERRO [runner] Panic: gofumpt: package "process" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 36 (should be < 35): goroutine 17575 [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 +0x277
panic({0x11c1640?, 0xc005de8450?})
        runtime/panic.go:785 +0x132
go/token.(*File).LineStart(0x1?, 0xc0074c3b80?)
        go/token/position.go:232 +0x168
github.com/golangci/golangci-lint/pkg/golinters/internal.toDiagnostic(0xc0060e2c00, {0x24, 0x24, {0x0, 0x0, 0x0}}, 0x0)
        github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go:254 +0x85
github.com/golangci/golangci-lint/pkg/golinters/internal.ExtractDiagnosticFromPatch(0xc006eba2a0, 0xc009b82c80, {0xc0008e5500, 0x30b}, 0xc0004c0360)
        github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go:245 +0x4a5
github.com/golangci/golangci-lint/pkg/golinters/gofumpt.runGofumpt(0xc0004c0360, 0xc006eba2a0, {0x16926e0, 0x21b8740}, {{0xc0000cdc60, 0x8}, {0x0, 0x0}, 0x0})
        github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go:86 +0x449
github.com/golangci/golangci-lint/pkg/golinters/gofumpt.New.func1.1(0x6c6c6977206c6c61?)
        github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go:52 +0x3d
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze.func3(0xc003adaa00, 0xc006eba2a0)
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:182 +0xeb
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze(0xc003adaa00)
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:208 +0xa9c
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc001395360, {0x13b98e0, 0x7}, 0xc005721f48)
        github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe(0xc00194ef00?)
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:54 +0x71
github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze.func2(0xc003adaa00)
        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 659
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:78 +0x1e9 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: gofumpt: package "process" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 36 (should be < 35) 
ERRO Running error: can't run linter goanalysis_metalinter
goanalysis_metalinter: gofumpt: package "process" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 36 (should be < 35) 

A minimal reproducible example or link to a public repository

// add your code here
Nope

Validation

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

Supporter

@oowl oowl added the bug Something isn't working label Jan 1, 2025
Copy link

boring-cyborg bot commented Jan 1, 2025

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

@ldez ldez self-assigned this Jan 1, 2025
@ldez
Copy link
Member

ldez commented Jan 1, 2025

@oowl can you provide a reproducible example? and your configuration.

@ldez ldez added the feedback required Requires additional feedback label Jan 1, 2025
@oowl
Copy link
Author

oowl commented Jan 1, 2025

@ldez check the code below can reproduce it.

package process

/*
#include <asm/types.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/inet_diag.h>
*/
import "C"

@ldez
Copy link
Member

ldez commented Jan 1, 2025

can you provide a complete reproducible example?

@oowl
Copy link
Author

oowl commented Jan 1, 2025

Let's follow this shell snippet for reproduce it.

$  /tmp cat process.go 
package process

/*
#include <asm/types.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/inet_diag.h>
*/
import "C"
run:
  skip-dirs-use-default: true
  timeout: 10m

output:
  formats: colored-line-number

linters-settings:
  gosmiple:
    checks: ["all"]

linters:
  enable:
    - asasalint
    - asciicheck
    - bidichk
    - contextcheck
    - decorder
    - dogsled
    - dupl
    - dupword
    - durationcheck
    - errcheck
    - errchkjson
    - errname
    - errorlint
    - copyloopvar
    - forbidigo
    - ginkgolinter
    - gocheckcompilerdirectives
    - goconst
    - gocritic
    - goimports
    - gofmt
    - gofumpt
    - gosec
    - gosimple
    - govet
    - ineffassign
    - loggercheck
    - misspell
    - prealloc
    - predeclared
    - rowserrcheck
    - revive
    - staticcheck
    - unused
 
issues:
  exclude-use-default: true
  exclude-dirs:
    - tunnel/tun2socks
    - store%                                                                                                                                                                                                  
$ /tmp /snap/bin/golangci-lint run --fix ./process.go
WARN [config_reader] The configuration option `run.skip-dirs-use-default` is deprecated, please use `issues.exclude-dirs-use-default`. 
WARN [linters_context] copyloopvar: this linter is disabled because the Go version (1.17) of your project is lower than Go 1.22 
ERRO [runner] Panic: gofumpt: package "process" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 36 (should be < 35): goroutine 1188 [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 +0x277
panic({0x11c1640?, 0xc001803ea0?})
        runtime/panic.go:785 +0x132
go/token.(*File).LineStart(0x1?, 0xc000721400?)
        go/token/position.go:232 +0x168
github.com/golangci/golangci-lint/pkg/golinters/internal.toDiagnostic(0xc001068660, {0x24, 0x24, {0x0, 0x0, 0x0}}, 0x0)
        github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go:254 +0x85
github.com/golangci/golangci-lint/pkg/golinters/internal.ExtractDiagnosticFromPatch(0xc00192a380, 0xc0008465a0, {0xc000675c00, 0x30b}, 0xc00007eae0)
        github.com/golangci/golangci-lint/pkg/golinters/internal/diff.go:245 +0x4a5
github.com/golangci/golangci-lint/pkg/golinters/gofumpt.runGofumpt(0xc00007eae0, 0xc00192a380, {0x16926e0, 0x21b8740}, {{0xc0007087c0, 0x6}, {0x0, 0x0}, 0x0})
        github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go:86 +0x449
github.com/golangci/golangci-lint/pkg/golinters/gofumpt.New.func1.1(0x4106fe?)
        github.com/golangci/golangci-lint/pkg/golinters/gofumpt/gofumpt.go:52 +0x3d
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze.func3(0xc0028633e0, 0xc00192a380)
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:182 +0xeb
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze(0xc0028633e0)
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_checker.go:208 +0xa9c
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc000955360, {0x13b98e0, 0x7}, 0xc001139748)
        github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe(0x0?)
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:54 +0x71
github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze.func2(0xc0028633e0)
        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 621
        github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:78 +0x1e9 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: gofumpt: package "process" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 36 (should be < 35) 
ERRO Running error: can't run linter goanalysis_metalinter
goanalysis_metalinter: gofumpt: package "process" (isInitialPkg: true, needAnalyzeSource: true): invalid line number 36 (should be < 35) 

@ldez ldez added area: cgo Related to CGO or line directives and removed feedback required Requires additional feedback labels Jan 1, 2025
@ldez ldez mentioned this issue Jan 1, 2025
@ldez ldez closed this as completed in #5272 Jan 1, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area: auto-fix area: cgo Related to CGO or line directives bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants