Skip to content

gci runtime error #3018

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
4 tasks done
ejain opened this issue Jul 26, 2022 · 4 comments · Fixed by #3019
Closed
4 tasks done

gci runtime error #3018

ejain opened this issue Jul 26, 2022 · 4 comments · Fixed by #3019
Labels
bug Something isn't working

Comments

@ejain
Copy link

ejain commented Jul 26, 2022

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

golangci-lint crashes with a nil pointer error, even though I can run [email protected] directly with the same option on the same code without any issues. If I disable gci in .golangci.yml, everything is fine.

Version of golangci-lint

v1.47.2

Configuration file

  ...
  gci:
    sections:
      - Std
      - Def
      - prefix(github.com/x/y)
  ...

Go environment

1.18.4

Verbose output of running

Running [/home/runner/golangci-lint-1.47.2-linux-amd64/golangci-lint run --out-format=github-actions --timeout=2m] in [] ...
  level=warning msg="[linters context] bodyclose is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649."
  level=error msg="[runner] Panic: gci: package \"env\" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference: goroutine 7404 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x65\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x155\npanic({0xf0a040, 0x1943970})\n\truntime/panic.go:838 +0x207\ngithub.com/golangci/golangci-lint/pkg/golinters.runGci(0xc006e32a90, 0xc001313dc0?, 0x0, 0xc0004b4890?)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/gci.go:89 +0x214\ngithub.com/golangci/golangci-lint/pkg/golinters.NewGci.func1.1(0xef8e80?)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/gci.go:61 +0x3b\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0031[23](https://github.com/bloomapi/bloomtext-backend/runs/7526089707?check_suite_focus=true#step:4:25)4b0)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:187 +0x9c4\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x1d\ngithub.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc002a44960, {0x102dec8, 0x3}, 0xc001c20748)\n\tgithub.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4a\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc0004f6cc0?)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:104 +0x85\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc0031234b0)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb4\ncreated by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1eb\n"
  level=warning msg="[runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: gci: package \"env\" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference"
  level=warning msg="[linters context] sqlclosecheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649."
  level=warning msg="[linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/[26](https://github.com/bloomapi/bloomtext-backend/runs/7526089707?check_suite_focus=true#step:4:28)49."
  level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: goanalysis_metalinter: gci: package \"env\" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference\n\n"

Code example or link to a public repository

// add your code here
@ejain ejain added the bug Something isn't working label Jul 26, 2022
@ldez ldez added the dependencies Relates to an upstream dependency label Jul 26, 2022
@ldez
Copy link
Member

ldez commented Jul 26, 2022

Hello,

can you provide a reproducible example?

thank you.

@ldez ldez removed the dependencies Relates to an upstream dependency label Jul 27, 2022
@ldez
Copy link
Member

ldez commented Jul 27, 2022

I'm able to reproduce the problem and I will fix the panic.

Your configuration is just invalid: Std and Def are not valid configuration options.
Use standard and default instead.

@ejain
Copy link
Author

ejain commented Jul 27, 2022

Thanks, that's it! Previous versions let me get away with the invalid (or deprecated?) configuration options...

@ldez
Copy link
Member

ldez commented Jul 27, 2022

Linter can change its configuration. We try to keep compatibility as much as we can, but we cannot control changes inside a linter.

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.

2 participants