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

Running error: can't run linter goanalysis_metalinter #4482

Closed
5 tasks done
demoManito opened this issue Mar 11, 2024 · 12 comments
Closed
5 tasks done

Running error: can't run linter goanalysis_metalinter #4482

demoManito opened this issue Mar 11, 2024 · 12 comments
Assignees
Labels
bug Something isn't working dependencies Relates to an upstream dependency

Comments

@demoManito
Copy link

demoManito commented Mar 11, 2024

Welcome

Description of the problem

Pull the latest code and use make build. It cannot be exploded accordingly.

GoLang Version: 1.21.8
golangci-lint Version: latest master make build

Version of golangci-lint

$ golangci-lint --version
# Paste output here
golangci-lint has version (devel) built with go1.21.8 from (unknown, mod sum: "") on (unknown)

Configuration

# paste configuration file or CLI flags here

Go environment

$ go version && go env
# paste output here

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here
INFO [config_reader] Config search paths: [./] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 10 linters: [errcheck forbidigo goimports gosimple govet ineffassign misspell staticcheck unused whitespace] 
INFO [loader] Go packages loading at mode 575 (name|types_sizes|compiled_files|deps|exports_file|files|imports) took 896.459292ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 70.753584ms 
INFO [linters_context/goanalysis] analyzers took 2m9.91934941s with top 10 stages: buildir: 14.901529871s, goimports: 5.670117284s, forbidigo: 5.642568598s, S1038: 2.781328369s, whitespace: 2.665187295s, directives: 2.568707869s, misspell: 2.506498657s, unused: 2.399164374s, isgenerated: 2.154990296s, errcheck: 1.803361748s 
ERRO [runner] Panic: httpresponse: package "chatroom" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference: goroutine 54483 [running]:
runtime/debug.Stack()
        /Users/jesse/.gvm/gos/go1.21.8/src/runtime/debug/stack.go:24 +0x64
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
        /Users/jesse/GolandProjects/golangci-lint/pkg/golinters/goanalysis/runner_action.go:108 +0x224
panic({0x101d79820?, 0x10271c140?})
        /Users/jesse/.gvm/gos/go1.21.8/src/runtime/panic.go:914 +0x218
go/types.(*Named).Obj(...)
        /Users/jesse/.gvm/gos/go1.21.8/src/go/types/named.go:295
golang.org/x/tools/go/analysis/passes/internal/analysisutil.IsNamedType({0x101ee5460?, 0x0?}, {0x1019b7503?, 0x100efaff4?}, {0x140046beab8?, 0x1?, 0x140046beb68?})
        /Users/jesse/.gvm/pkgsets/go1.21.8/global/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/internal/analysisutil/util.go:123 +0x38
golang.org/x/tools/go/analysis/passes/httpresponse.isHTTPFuncOrMethodOnClient(0x140192e1810, 0x1?)
        /Users/jesse/.gvm/pkgsets/go1.21.8/global/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/httpresponse/httpresponse.go:122 +0x144
golang.org/x/tools/go/analysis/passes/httpresponse.run.func1({0x101ee4830?, 0x1400f49d6c0?}, 0x68?, {0x1401a49a400, 0x5, 0x10})
        /Users/jesse/.gvm/pkgsets/go1.21.8/global/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/httpresponse/httpresponse.go:62 +0x58
golang.org/x/tools/go/ast/inspector.(*Inspector).WithStack(0x140085c6420, {0x140046bec88?, 0x1?, 0x14000e8a0f0?}, 0x14003033c98)
        /Users/jesse/.gvm/pkgsets/go1.21.8/global/pkg/mod/golang.org/x/tools@v0.19.0/go/ast/inspector/inspector.go:148 +0x168
golang.org/x/tools/go/analysis/passes/httpresponse.run(0x1401b9396c0)
        /Users/jesse/.gvm/pkgsets/go1.21.8/global/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/httpresponse/httpresponse.go:57 +0x104
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0x140054888b0)
        /Users/jesse/GolandProjects/golangci-lint/pkg/golinters/goanalysis/runner_action.go:190 +0x99c
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
        /Users/jesse/GolandProjects/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x20
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0x14001d4c190, {0x101a01a2d, 0xc}, 0x14004472730)
        /Users/jesse/GolandProjects/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0x1013975c0?)
        /Users/jesse/GolandProjects/golangci-lint/pkg/golinters/goanalysis/runner_action.go:111 +0x78
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0x140054888b0)
        /Users/jesse/GolandProjects/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb0
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze in goroutine 403
        /Users/jesse/GolandProjects/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x184 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: httpresponse: package "chatroom" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference 
INFO [runner] processing took 1.292µs with stages: max_same_issues: 500ns, skip_dirs: 166ns, cgo: 125ns, path_prefixer: 42ns, severity-rules: 42ns, identifier_marker: 42ns, autogenerated_exclude: 42ns, path_prettifier: 42ns, diff: 42ns, max_from_linter: 42ns, sort_results: 42ns, source_code: 42ns, skip_files: 41ns, uniq_by_line: 41ns, nolint: 41ns, fixer: 0s, exclude-rules: 0s, filename_unadjuster: 0s, exclude: 0s, max_per_file_from_linter: 0s, path_shortener: 0s 
INFO [runner] linters took 4.73555075s with stages: goanalysis_metalinter: 4.735327791s 
ERRO Running error: can't run linter goanalysis_metalinter
goanalysis_metalinter: httpresponse: package "chatroom" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference 
INFO Memory: 59 samples, avg is 533.3MB, max is 936.1MB 
INFO Execution took 5.711658375s 

A minimal reproducible example or link to a public repository

// add your code here

Validation

  • Yes, I've included all information above (version, config, etc.).
@demoManito demoManito added the bug Something isn't working label Mar 11, 2024
Copy link

boring-cyborg bot commented Mar 11, 2024

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

@ldez ldez added question Further information is requested and removed bug Something isn't working labels Mar 11, 2024
@ldez
Copy link
Member

ldez commented Mar 11, 2024

Hello,

can you provide a reproducible code example and your configuration?

@ldez ldez added bug Something isn't working feedback required Requires additional feedback and removed question Further information is requested labels Mar 11, 2024
@ldez
Copy link
Member

ldez commented Mar 11, 2024

This issue doesn't provide:

  • the exact golangci-lint version (master, latest, and devel are not precise versions)
  • the configuration
  • a reproducible example

With the stacktrace, the only things that I can know are it may be related to the govet rule httpresponse or golang.org/x/tools@v0.19.0.

Without more information, it can take days to find out how to recreate the problem (if the problem can be recreated) and how to fix it.


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
# or exact commit reference
cat .golangci.yml
go version && go env
golangci-lint cache clean
golangci-lint run -v

@firelizzard18
Copy link
Contributor

firelizzard18 commented Mar 11, 2024

I have this same issue on https://gitlab.com/accumulatenetwork/accumulate/ when I update to golangci-lint bleeding edge (for the new plugin system). Once I work around it for production I'll try to make a repro branch.

Ultimately it appears there's a bug in golang.org/x/tools.

@firelizzard18
Copy link
Contributor

golangci-repro-4482 reproduces the panic on my PC. Reverting golang.org/x/tools to v0.18.0 resolves the issue. Here's the full log:

log
INFO [config_reader] Config search paths: [./ /home/firelizzard/src/Accumulate/accumulate /home/firelizzard/src/Accumulate /home/firelizzard/src /home/firelizzard /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO Loaded : rangevarref                         
INFO Loaded : noprint                             
INFO Loaded : nodebug                             
INFO [lintersdb] Active 1 linters: [govet]        
INFO [loader] Go packages loading at mode 575 (name|compiled_files|deps|exports_file|files|imports|types_sizes) took 448.562894ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 45.95519ms 
INFO [linters_context/goanalysis] analyzers took 636.641834ms with top 10 stages: inspect: 117.639198ms, printf: 89.964436ms, ctrlflow: 62.623472ms, copylocks: 53.980913ms, assign: 29.201073ms, lostcancel: 26.764156ms, bools: 21.786709ms, composites: 18.945616ms, unsafeptr: 17.460426ms, unreachable: 15.820847ms 
ERRO [runner] Panic: httpresponse: package "simulator" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference: goroutine 28424 [running]:
runtime/debug.Stack()
        /home/firelizzard/sdk/go1.22.1/src/runtime/debug/stack.go:24 +0x5e
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
        /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_action.go:108 +0x277
panic({0x16e86a0?, 0x2327480?})
        /home/firelizzard/sdk/go1.22.1/src/runtime/panic.go:770 +0x132
go/types.(*Named).Obj(...)
        /home/firelizzard/sdk/go1.22.1/src/go/types/named.go:295
golang.org/x/tools/go/analysis/passes/internal/analysisutil.IsNamedType({0x1afa470?, 0x0?}, {0x185e739, 0x8}, {0xc0027ebaf8, 0x1, 0x928645?})
        /home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/internal/analysisutil/util.go:123 +0x49
golang.org/x/tools/go/analysis/passes/httpresponse.isHTTPFuncOrMethodOnClient(0xc00dd04240, 0xc014064100?)
        /home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/httpresponse/httpresponse.go:122 +0xfb
golang.org/x/tools/go/analysis/passes/httpresponse.run.func1({0x1af9b10?, 0xc00cdc7c80?}, 0x10?, {0xc014064100, 0xc, 0x10})
        /home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/httpresponse/httpresponse.go:62 +0x73
golang.org/x/tools/go/ast/inspector.(*Inspector).WithStack(0xc0124d1d88, {0xc0034c64b8?, 0x2353000?, 0x600?}, 0xc00164bcc8)
        /home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.19.0/go/ast/inspector/inspector.go:148 +0x188
golang.org/x/tools/go/analysis/passes/httpresponse.run(0xc01df8bc70)
        /home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/httpresponse/httpresponse.go:57 +0x112
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc00353b5b0)
        /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_action.go:190 +0xa02
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
        /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_action.go:112 +0x17
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc00259e910, {0x18a8df4, 0xc}, 0xc0034c6748)
        /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc00045e2a0?)
        /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_action.go:111 +0x7a
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc00353b5b0)
        /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xa8
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze in goroutine 800
        /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x205 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: httpresponse: package "simulator" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference 
INFO [runner] processing took 1.973µs with stages: max_same_issues: 474ns, skip_dirs: 237ns, nolint: 167ns, max_from_linter: 131ns, cgo: 105ns, autogenerated_exclude: 97ns, exclude-rules: 95ns, skip_files: 94ns, identifier_marker: 94ns, path_prettifier: 90ns, filename_unadjuster: 89ns, fixer: 37ns, diff: 31ns, severity-rules: 30ns, uniq_by_line: 30ns, sort_results: 30ns, exclude: 30ns, source_code: 30ns, path_shortener: 28ns, path_prefixer: 27ns, max_per_file_from_linter: 27ns 
INFO [runner] linters took 554.127017ms with stages: goanalysis_metalinter: 554.104557ms 
ERRO Running error: can't run linter goanalysis_metalinter
goanalysis_metalinter: httpresponse: package "simulator" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference 
INFO Memory: 12 samples, avg is 188.0MB, max is 536.2MB 
INFO Execution took 1.051656194s

firelizzard18 added a commit to AccumulateNetwork/accumulate that referenced this issue Mar 11, 2024
@ldez
Copy link
Member

ldez commented Mar 11, 2024

Thank you, as a temporary fix, I will revert golang.org/x/tools

@ldez
Copy link
Member

ldez commented Mar 12, 2024

sadly we cannot revert easily... 😢

It's related to this commit golang/tools@c111c4dfa

I know where the bug is but I don't find a way to create a minimal reproducible example.

@ldez
Copy link
Member

ldez commented Mar 12, 2024

I submitted a bug report golang/go#66259
@firelizzard18 I linked your branch.
Can you remove the plugin section of the .golangci.yml inside this branch?


The problem is related to func ChainFromJSON(s *string) (*[32]byte, error) {, the *[32]byte produces the panic 🤔


I found the problem -> golang/go#66259 (comment)

@ldez ldez removed the feedback required Requires additional feedback label Mar 12, 2024
@ldez ldez self-assigned this Mar 12, 2024
@firelizzard18
Copy link
Contributor

firelizzard18 commented Mar 13, 2024

I stripped down .golangci.yml to the minimum needed to reproduce the issue.

Thanks for your work on tracing this to the root cause.

@ldez
Copy link
Member

ldez commented Mar 13, 2024

I created a minimal example with only 2 files (it was not fun to remove all your code file by file and line by line 😄)

golang/go#66259 (comment)

The feedback on the Go issue is sparse, the CL attached will fix the problem but we have to wait

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

ldez commented Apr 8, 2024

Fixed by #4620

@ldez ldez closed this as completed Apr 8, 2024
@demoManito
Copy link
Author

thanks @ldez

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

3 participants