Skip to content

staticcheck(SA4023): invalid memory address or nil pointer dereference #6746

Description

@jhawk28

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

How did you install golangci-lint?

go install

Description of the problem

Using the latest version of golangci-lint (go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest).

Fails with following stacktrace:

Panic: SA4023: package "sui" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference: goroutine 43176 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:26 +0x64
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*action).analyzeSafe.func1()
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/goanalysis/runner_action.go:55 +0x1d8
panic({0x1044b87c8?, 0x10479a280?})
	/usr/local/go/src/runtime/panic.go:859 +0x120
honnef.co/go/tools/go/ir.(*Function).Source(...)
	/Users/joshua/go/pkg/mod/honnef.co/go/tools@v0.8.0/go/ir/ssa.go:1979
honnef.co/go/tools/go/ir/irutil.isTrivial(0x6e8bb31d5ce0?, 0x6e8bc337f2c0?)
	/Users/joshua/go/pkg/mod/honnef.co/go/tools@v0.8.0/go/ir/irutil/stub.go:49 +0x18
honnef.co/go/tools/go/ir/irutil.IsTrivial(...)
	/Users/joshua/go/pkg/mod/honnef.co/go/tools@v0.8.0/go/ir/irutil/stub.go:45
honnef.co/go/tools/staticcheck/sa4023.run(0x6e8bb31d5ce0)
	/Users/joshua/go/pkg/mod/honnef.co/go/tools@v0.8.0/staticcheck/sa4023/sa4023.go:184 +0x600
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*action).analyze.func3(...)
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/goanalysis/runner_checker.go:180
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*action).analyze(0x6e8bb69eee40)
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/goanalysis/runner_checker.go:206 +0x9d8
github.com/golangci/golangci-lint/v2/pkg/timeutils.(*Stopwatch).TrackStage(0x6e8bb50c4b40, {0x1030b03c0, 0x6}, 0x6e8bb5e58700)
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*action).analyzeSafe(0x6e8bb69eee40?)
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/goanalysis/runner_action.go:59 +0x64
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*loadingPackage).analyze.func2()
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/goanalysis/runner_loadingpackage.go:107 +0x6c
golang.org/x/sync/errgroup.(*Group).Go.func1()
	/Users/joshua/go/pkg/mod/golang.org/x/sync@v0.22.0/errgroup/errgroup.go:93 +0x4c
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 459
	/Users/joshua/go/pkg/mod/golang.org/x/sync@v0.22.0/errgroup/errgroup.go:78 +0x98

Version of golangci-lint

golangci-lint has version 2.13.1 built with go1.27.0 from (unknown, modified: ?, mod sum: "h1:RuM4OcluM4xFQcGuRE6R7jA33pqxK/W1EsBxpugdZjg=") on (unknown)

Configuration

Details
version: "2"
run:
  tests: false
  timeout: 5m
  modules-download-mode: readonly

linters:
  default: standard
  exclusions:
    rules:
      - linters:
          - staticcheck
        text: "QF1008:" # Omit embedded fields from selector expression.
      - linters:
          - staticcheck
        text: "QF1001:" # could apply De Morgan's law

Go environment

Details
go version go1.27.0 darwin/arm64

Verbose output of running

Details
INFO golangci-lint has version 2.13.1 built with go1.27.0 from (unknown, modified: ?, mod sum: "h1:RuM4OcluM4xFQcGuRE6R7jA33pqxK/W1EsBxpugdZjg=") on (unknown) 
INFO [config_reader] Config search paths: [./ /Users/joshua/repos/node /Users/joshua/repos /Users/joshua /Users /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [config_reader] Module name "github.com/quiknode-labs/node/v4" 
INFO [goenv] Read go env for 15.686459ms: map[string]string{"GOCACHE":"/Users/joshua/Library/Caches/go-build", "GOROOT":"/usr/local/go"} 
INFO [lintersdb] Active 5 linters: [errcheck govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 8767 (deps|files|imports|types_sizes|compiled_files|exports_file|name) took 1.226075667s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 17.248209ms 
INFO [linters_context/goanalysis] analyzers took 6.808655291s with top 10 stages: nilness: 580.686999ms, unused: 552.833255ms, buildir: 409.546679ms, S1008: 199.469463ms, directives: 193.725506ms, fact_purity: 190.381198ms, printf: 175.319892ms, S1038: 153.051365ms, typeindex: 146.696328ms, fact_deprecated: 145.191254ms 
ERRO [runner] Panic: SA4023: package "sui" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference: goroutine 45299 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:26 +0x64
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*action).analyzeSafe.func1()
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/goanalysis/runner_action.go:55 +0x1d8
panic({0x102e347c8?, 0x103116280?})
	/usr/local/go/src/runtime/panic.go:859 +0x120
honnef.co/go/tools/go/ir.(*Function).Source(...)
	/Users/joshua/go/pkg/mod/honnef.co/go/tools@v0.8.0/go/ir/ssa.go:1979
honnef.co/go/tools/go/ir/irutil.isTrivial(0x215d0c4f9c00?, 0x215d00b21d40?)
	/Users/joshua/go/pkg/mod/honnef.co/go/tools@v0.8.0/go/ir/irutil/stub.go:49 +0x18
honnef.co/go/tools/go/ir/irutil.IsTrivial(...)
	/Users/joshua/go/pkg/mod/honnef.co/go/tools@v0.8.0/go/ir/irutil/stub.go:45
honnef.co/go/tools/staticcheck/sa4023.run(0x215d0c4f9c00)
	/Users/joshua/go/pkg/mod/honnef.co/go/tools@v0.8.0/staticcheck/sa4023/sa4023.go:184 +0x600
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*action).analyze.func3(...)
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/goanalysis/runner_checker.go:180
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*action).analyze(0x215cff13ce40)
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/goanalysis/runner_checker.go:206 +0x9d8
github.com/golangci/golangci-lint/v2/pkg/timeutils.(*Stopwatch).TrackStage(0x215cfc2f4140, {0x101a2c3c0, 0x6}, 0x215cfebfe700)
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/timeutils/stopwatch.go:111 +0x44
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*action).analyzeSafe(0x215cff13ce40?)
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/goanalysis/runner_action.go:59 +0x64
github.com/golangci/golangci-lint/v2/pkg/goanalysis.(*loadingPackage).analyze.func2()
	/Users/joshua/go/pkg/mod/github.com/golangci/golangci-lint/v2@v2.13.1/pkg/goanalysis/runner_loadingpackage.go:107 +0x6c
golang.org/x/sync/errgroup.(*Group).Go.func1()
	/Users/joshua/go/pkg/mod/golang.org/x/sync@v0.22.0/errgroup/errgroup.go:93 +0x4c
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 2712
	/Users/joshua/go/pkg/mod/golang.org/x/sync@v0.22.0/errgroup/errgroup.go:78 +0x98 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: SA4023: package "sui" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference 
INFO [runner/exclusion_rules] Skipped 0 issues by rules: [Text: "QF1008:", Linters: "staticcheck"] 
INFO [runner/exclusion_rules] Skipped 0 issues by rules: [Text: "QF1001:", Linters: "staticcheck"] 
INFO [runner] processing took 4.626µs with stages: exclusion_rules: 3.666µs, max_same_issues: 250ns, exclusion_paths: 167ns, cgo: 84ns, sort_results: 83ns, max_from_linter: 83ns, severity-rules: 42ns, max_per_file_from_linter: 42ns, diff: 42ns, filename_unadjuster: 42ns, path_absoluter: 42ns, uniq_by_line: 42ns, nolint_filter: 41ns, path_shortener: 0s, fixer: 0s, path_relativity: 0s, invalid_issue: 0s, source_code: 0s, path_prettifier: 0s, generated_file_filter: 0s 
INFO [runner] linters took 1.663850708s with stages: goanalysis_metalinter: 1.66381275s 
ERRO Running error: can't run linter goanalysis_metalinter
goanalysis_metalinter: SA4023: package "sui" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference 
INFO Memory: 31 samples, avg is 167.7MB, max is 706.5MB 
INFO Execution took 2.923673958s 

A minimal reproducible example or link to a public repository

Details
// add your code here

Validation

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

Supporter

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdependenciesRelates to an upstream dependency

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions