-
-
Notifications
You must be signed in to change notification settings - Fork 403
Closed
Labels
Description
I'm new to staticcheck and one of my projects causes a panic.
> staticcheck .
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x95abea]
goroutine 217 [running]:
go/types.(*StdSizes).Sizeof(0x0, {0xd5ea48?, 0x100bf40})
go/types/sizes.go:228 +0x2ea
honnef.co/go/tools/staticcheck.checkAtomicAlignmentImpl(0xc000074780)
honnef.co/go/tools@v0.4.5/staticcheck/lint.go:773 +0x65
honnef.co/go/tools/staticcheck.checkCalls.func1(0xc000234ce8?, {0xd66af0?, 0xc0000da4d0}, 0xc0004a8140)
honnef.co/go/tools@v0.4.5/staticcheck/lint.go:3293 +0x32d
honnef.co/go/tools/staticcheck.eachCall(0xc0002ce780, 0xc000234d38)
honnef.co/go/tools@v0.4.5/staticcheck/lint.go:2662 +0x12b
honnef.co/go/tools/staticcheck.checkCalls(0xc000234d78?, 0x80da8f?)
honnef.co/go/tools@v0.4.5/staticcheck/lint.go:3334 +0x95
honnef.co/go/tools/staticcheck.init.makeCallCheckerAnalyzer.callChecker.func42(0xbf1ca0?)
honnef.co/go/tools@v0.4.5/staticcheck/lint.go:3261 +0x17
honnef.co/go/tools/lintcmd/runner.(*analyzerRunner).do(0xc000088c60, {0xd621c8?, 0xc00032ebe0})
honnef.co/go/tools@v0.4.5/lintcmd/runner/runner.go:992 +0x71e
honnef.co/go/tools/lintcmd/runner.genericHandle({0xd621c8?, 0xc00032ebe0}, {0xd621c8?, 0xc0000965a0?}, 0xc14880?, 0x0, 0xc000235300)
honnef.co/go/tools@v0.4.5/lintcmd/runner/runner.go:817 +0x113
honnef.co/go/tools/lintcmd/runner.(*subrunner).runAnalyzers(0xc0000f5ae0, 0xc00024d0e0, 0xc000074230)
honnef.co/go/tools@v0.4.5/lintcmd/runner/runner.go:1065 +0x716
honnef.co/go/tools/lintcmd/runner.(*subrunner).doUncached(0x0?, 0xc00024d0e0)
honnef.co/go/tools@v0.4.5/lintcmd/runner/runner.go:720 +0x189
honnef.co/go/tools/lintcmd/runner.(*subrunner).do(0xc0000f5ae0, {0xd62210?, 0xc00024d0e0})
honnef.co/go/tools@v0.4.5/lintcmd/runner/runner.go:577 +0x948
honnef.co/go/tools/lintcmd/runner.(*Runner).Run.func2({0xd62210?, 0xc00024d0e0?})
honnef.co/go/tools@v0.4.5/lintcmd/runner/runner.go:1268 +0x2a
honnef.co/go/tools/lintcmd/runner.genericHandle({0xd62210?, 0xc00024d0e0}, {0xd62210?, 0xc00024cfc0?}, 0x8040102?, 0xc00047e4d0, 0xc000523880)
honnef.co/go/tools@v0.4.5/lintcmd/runner/runner.go:817 +0x113
created by honnef.co/go/tools/lintcmd/runner.(*Runner).Run in goroutine 1
honnef.co/go/tools@v0.4.5/lintcmd/runner/runner.go:1267 +0x4e5I managed to boil it down to a single file containing the following:
package foo
import (
"sync/atomic"
"github.com/rcrowley/go-metrics"
)
var (
sessionCount int64
g = metrics.NewRegisteredFunctionalGauge("session_count", nil, func() int64 { return atomic.LoadInt64(&sessionCount) })
)The issue doesn't occur if I switch to WSL (Ubuntu) and use the exact same staticcheck version (installed via Brew), so I guess this is a Windows specific issue.
- staticcheck.exe 2023.1.5 (v0.4.5)
- go version go1.21.0 windows/amd64
- github.com/rcrowley/go-metrics@v0.0.0-20201227073835-cf1acfcdf475
set GO111MODULE=auto
set GOARCH=amd64
set GOCACHE=C:\Users\Nathan\AppData\Local\go-build
set GOENV=C:\Users\Nathan\AppData\Roaming\go\env
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOMODCACHE=C:\Users\Nathan\go\pkg\mod
set GOOS=windows
set GOPATH=C:\Users\Nathan\go
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\Nathan\scoop\apps\go\current
set GOSUMDB=sum.golang.org
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\Nathan\scoop\apps\go\current\pkg\tool\windows_amd64
set GOVERSION=go1.21.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=D:\Ryver\ryver\services\forseti\go.mod
set CGO_CFLAGS=-O2 -g
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\Nathan\AppData\Local\Temp\go-build3794376127=/tmp/go-build -gno-record-gcc-switches
Reactions are currently unavailable