Closed
Description
- 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
While trying to run golangci-lint on this project, I get this output:
$ cd v5 && golangci-lint run --build-tags=all
WARN [linters context] Panic: SA4023: package "core" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference: goroutine 3527 [running]:
runtime/debug.Stack(0x10329cf, 0x3c, 0xc005236818)
runtime/debug/stack.go:24 +0x9f
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1(0xc001769530)
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x1be
panic(0xe660c0, 0x16df040)
runtime/panic.go:965 +0x1b9
honnef.co/go/tools/analysis/report.getRange(0x7f37e7cb2960, 0xc005056180, 0xc0064d4d00, 0xc005236b88, 0xc0005e0c00)
honnef.co/go/[email protected]/analysis/report/report.go:136 +0xf5
honnef.co/go/tools/analysis/report.Related.func1(0xc0064d4d40)
honnef.co/go/[email protected]/analysis/report/report.go:47 +0x56
honnef.co/go/tools/analysis/report.Report(0xc0045de4e0, 0x1154b60, 0xc0050581c0, 0xc0064b1e80, 0x1d, 0xc005e6dcf8, 0x1, 0x1)
honnef.co/go/[email protected]/analysis/report/report.go:150 +0x6d
honnef.co/go/tools/staticcheck.CheckTypedNilInterface(0xc0045de4e0, 0x2e0a68f7, 0x17ee7a0, 0xc0014dbcc0, 0x2)
honnef.co/go/[email protected]/staticcheck/lint.go:4309 +0xb0d
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc001769530)
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:187 +0x9f2
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x2a
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc001516000, 0xf81f6b, 0x6, 0xc0006b7770)
github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4d
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc001769530)
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:104 +0x91
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc00360e5a0, 0xc001769530)
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x65
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x316
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: SA4023: package "core" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference
ERRO Running error: goanalysis_metalinter: SA4023: package "core" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.39.0 built from 9aea4aee on 2021-03-26T08:02:53Z
Incidentally, the problem does NOT occur when I use v1.38.0 of the linter on the same code.
Edit: Unfortunately, even version 1.38.0 fails when using Go 1.12, but works on Go 1.14
Edit2: It seems that v1.37.0 works on both Go 1.12 and 1.14
Config file
We do not use a config file in this project.
Go environment
$ go version && go env
go version go1.14.15 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/padams/.cache/go-build"
GOENV="/home/padams/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/padams/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/work/cores/go/v5/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build150186608=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /work/cores/go/v5 /work/cores/go /work/cores /work / /home/padams]
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [loader] Using build tags: [all]
INFO [loader] Go packages loading at mode 575 (compiled_files|imports|name|types_sizes|deps|exports_file|files) took 292.001622ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 20.751252ms
INFO [linters context/goanalysis] analyzers took 14.154915919s with top 10 stages: buildir: 8.42410793s, fact_deprecated: 717.481068ms, ctrlflow: 670.217254ms, fact_purity: 642.603359ms, printf: 614.057309ms, nilness: 589.945503ms, SA5012: 583.016043ms, typedness: 508.798802ms, inspect: 446.680217ms, S1038: 124.164152ms
WARN [linters context] Panic: SA4023: package "core" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference: goroutine 3651 [running]:
runtime/debug.Stack(0x10329cf, 0x3c, 0xc003c56818)
runtime/debug/stack.go:24 +0x9f
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1(0xc0015fc270)
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x1be
panic(0xe660c0, 0x16df040)
runtime/panic.go:965 +0x1b9
honnef.co/go/tools/analysis/report.getRange(0x7f7cd406b728, 0xc005683c80, 0xc00a2d6200, 0xc003c56b88, 0xc00021a800)
honnef.co/go/[email protected]/analysis/report/report.go:136 +0xf5
honnef.co/go/tools/analysis/report.Related.func1(0xc00a2d6280)
honnef.co/go/[email protected]/analysis/report/report.go:47 +0x56
honnef.co/go/tools/analysis/report.Report(0xc000b12b60, 0x1154b60, 0xc0055c2930, 0xc01b6761a0, 0x1d, 0xc0013e3cf8, 0x1, 0x1)
honnef.co/go/[email protected]/analysis/report/report.go:150 +0x6d
honnef.co/go/tools/staticcheck.CheckTypedNilInterface(0xc000b12b60, 0xd034d536, 0x17ee7a0, 0xc006e9e340, 0x2)
honnef.co/go/[email protected]/staticcheck/lint.go:4309 +0xb0d
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0015fc270)
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:187 +0x9f2
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x2a
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc001105590, 0xf81f6b, 0x6, 0xc000500f70)
github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4d
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc0015fc270)
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:104 +0x91
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc001a8cd40, 0xc0015fc270)
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x65
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x316
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: SA4023: package "core" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference
INFO [runner] processing took 5.231µs with stages: nolint: 911ns, path_prettifier: 869ns, max_same_issues: 662ns, skip_dirs: 635ns, source_code: 361ns, max_from_linter: 276ns, uniq_by_line: 234ns, autogenerated_exclude: 175ns, cgo: 148ns, path_shortener: 146ns, identifier_marker: 146ns, filename_unadjuster: 140ns, skip_files: 135ns, diff: 118ns, sort_results: 55ns, exclude-rules: 47ns, exclude: 46ns, max_per_file_from_linter: 45ns, severity-rules: 42ns, path_prefixer: 40ns
INFO [runner] linters took 3.174377908s with stages: goanalysis_metalinter: 3.174254068s
ERRO Running error: goanalysis_metalinter: SA4023: package "core" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference
INFO Memory: 35 samples, avg is 481.4MB, max is 878.5MB
INFO Execution took 3.492844544s
Code example or link to a public repository
The code that is causing this error is located at: https://github.com/IBM/go-sdk-core, branch="mdk/empty-body". Note that this problem does not occur on branch "main", only on "mdk/empty-body".
Steps to reproduce:
git clone https://github.com/IBM/go-sdk-core
cd go-sdk-core
git checkout mdk/empty-body
make lint
(or...cd v5 && golangci-lint run -v --build-tags=all
)