> staticcheck -version
staticcheck (no version)
> staticcheck -debug.version
staticcheck (no version)
Compiled with Go version: go1.12.10
Built without Go modules
> go version
go version go1.12.10 darwin/amd64
> go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/1t/zfh5jbts7f1919y3fv2p8qhm7bxt0p/T/go-build671232555=/tmp/go-build -gno-record-gcc-switches -fno-common"
The commands we're running are:
> go get -u honnef.co/go/tools/cmd/staticcheck
> staticcheck ./...
Which causes the following panic...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x12ca936]
goroutine 665 [running]:
honnef.co/go/tools/ssa.emitCompare(0xc0030ecb60, 0x27, 0x17c40e0, 0xc0032ae780, 0x17c4860, 0xc0032ae7d0, 0x26e0e8a, 0xc002448ae8, 0xc001095701)
$GOPATH/src/honnef.co/go/tools/ssa/emit.go:125 +0x586
honnef.co/go/tools/ssa.(*builder).expr0(0xc002449628, 0xc0030ecb60, 0x17ba580, 0xc000af7fb0, 0x7, 0x17b2240, 0x1bd8be0, 0x0, 0x0, 0xc002448d20, ...)
$GOPATH/src/honnef.co/go/tools/ssa/builder.go:629 +0x25fb
honnef.co/go/tools/ssa.(*builder).expr(0xc002449628, 0xc0030ecb60, 0x17ba580, 0xc000af7fb0, 0xc003183b40, 0x20)
$GOPATH/src/honnef.co/go/tools/ssa/builder.go:520 +0x27e
honnef.co/go/tools/ssa.(*builder).cond(0xc002449628, 0xc0030ecb60, 0x17ba580, 0xc000af7fb0, 0xc0032b2240, 0xc0032b23c0)
$GOPATH/src/honnef.co/go/tools/ssa/builder.go:111 +0x8c
honnef.co/go/tools/ssa.(*builder).stmt(0xc002449628, 0xc0030ecb60, 0x17baa80, 0xc0016e4880)
$GOPATH/src/honnef.co/go/tools/ssa/builder.go:2084 +0x25c8
honnef.co/go/tools/ssa.(*builder).stmtList(0xc002449628, 0xc0030ecb60, 0xc00149dac0, 0x2, 0x2)
$GOPATH/src/honnef.co/go/tools/ssa/builder.go:783 +0x72
honnef.co/go/tools/ssa.(*builder).stmt(0xc002449628, 0xc0030ecb60, 0x17ba5c0, 0xc001b720c0)
$GOPATH/src/honnef.co/go/tools/ssa/builder.go:2072 +0x207f
honnef.co/go/tools/ssa.(*builder).buildFunction(0xc002449628, 0xc0030ecb60)
$GOPATH/src/honnef.co/go/tools/ssa/builder.go:2166 +0x2e3
honnef.co/go/tools/ssa.(*builder).buildFuncDecl(0xc002449628, 0xc0017902a0, 0xc001b720f0)
$GOPATH/src/honnef.co/go/tools/ssa/builder.go:2197 +0xed
honnef.co/go/tools/ssa.(*Package).build(0xc0017902a0)
$GOPATH/src/honnef.co/go/tools/ssa/builder.go:2314 +0xd5e
sync.(*Once).Do(0xc0017902e0, 0xc00049d790)
/usr/local/go/src/sync/once.go:44 +0xb3
honnef.co/go/tools/ssa.(*Package).Build(0xc0017902a0)
$GOPATH/src/honnef.co/go/tools/ssa/builder.go:2232 +0x54
honnef.co/go/tools/internal/passes/buildssa.run(0xc0001154a0, 0x432de177, 0x1be88a0, 0xc0007b3000, 0x800)
$GOPATH/src/honnef.co/go/tools/internal/passes/buildssa/buildssa.go:70 +0x27e
honnef.co/go/tools/lint.(*Runner).runAnalysisUser(0xc000176780, 0xc0001154a0, 0xc0015db7c0, 0xc0008aa450, 0xc0006e9c68, 0x18, 0x18)
$GOPATH/src/honnef.co/go/tools/lint/runner.go:492 +0x2aa
honnef.co/go/tools/lint.(*Runner).runAnalysis(0xc000176780, 0xc0015db7c0, 0x0, 0x0, 0x0, 0x0)
$GOPATH/src/honnef.co/go/tools/lint/runner.go:366 +0x4cb
honnef.co/go/tools/lint.(*Runner).runAnalysisUser(0xc000176780, 0xc000115400, 0xc0015da000, 0xc0008aa3f0, 0xc00123cf58, 0xc00021a680, 0x3d)
$GOPATH/src/honnef.co/go/tools/lint/runner.go:478 +0xe8
honnef.co/go/tools/lint.(*Runner).runAnalysis(0xc000176780, 0xc0015da000, 0x0, 0x0, 0x0, 0x0)
$GOPATH/src/honnef.co/go/tools/lint/runner.go:366 +0x4cb
honnef.co/go/tools/lint.(*Runner).processPkg.func3(0xc0016e8490, 0xc0004858c0, 0xc000176780, 0xc00021a680, 0xc0015da000, 0xc0007b2000, 0x7e, 0x7e, 0x37)
$GOPATH/src/honnef.co/go/tools/lint/runner.go:897 +0x8e
created by honnef.co/go/tools/lint.(*Runner).processPkg
$GOPATH/src/honnef.co/go/tools/lint/runner.go:892 +0xa52
I believe the files referenced in the panic correspond to the commit that was merged into master 17 hours ago #8b6dd4f
staticcheck ./...
Can you share which code specifically you're running staticcheck on? Is it publicly available?
I believe the files referenced in the panic correspond to the commit that was merged into master 17 hours ago #8b6dd4f
Are you saying that because you've checked out that commit and confirmed it crashes in the same way? In total, 6 commits touched emit.go recently:
and large portions of 8b6dd4f were reverted by 404ac88
At any rate, knowing the actual code that staticcheck crashes on would be helpful. It seems to work fine on anything I've thrown at it during testing, which includes staticcheck's code base itself and the entire Go standard library. That indicates to me that it's not crashing on a common code pattern, but something more subtle we didn't consider.
We are running into the same. Travis builds were running fine till yesterday.
Here's our travis build: https://travis-ci.org/libopenstorage/autopilot/builds/592816197
Here is the stack trace
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x6bbaed]
goroutine 34710 [running]:
honnef.co/go/tools/ssa.emitCompare(0xc00ba404e0, 0x27, 0xb38f40, 0xc00abccd70, 0xb396c0, 0xc00abccdc0, 0x547c5ea, 0xc00abc86c0, 0xb38ca0)
/home/travis/gopath/src/honnef.co/go/tools/ssa/emit.go:125 +0x4bd
honnef.co/go/tools/ssa.(*builder).expr0(0xc0095ab5b0, 0xc00ba404e0, 0xb34360, 0xc00bd75a10, 0x7, 0xb31800, 0xf098c0, 0x0, 0x0, 0x2ad52bb58d08, ...)
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:629 +0x259a
honnef.co/go/tools/ssa.(*builder).expr(0xc0095ab5b0, 0xc00ba404e0, 0xb34360, 0xc00bd75a10, 0xc00abd0760, 0x8)
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:520 +0x277
honnef.co/go/tools/ssa.(*builder).cond(0xc0095ab5b0, 0xc00ba404e0, 0xb34360, 0xc00bd75a10, 0xc00abc8b40, 0xc00abc8c00)
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:111 +0x8c
honnef.co/go/tools/ssa.(*builder).stmt(0xc0095ab5b0, 0xc00ba404e0, 0xb34860, 0xc002c5c200)
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:2084 +0x25ab
honnef.co/go/tools/ssa.(*builder).stmtList(0xc0095ab5b0, 0xc00ba404e0, 0xc000a95d00, 0x5, 0x8)
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:783 +0x72
honnef.co/go/tools/ssa.(*builder).stmt(0xc0095ab5b0, 0xc00ba404e0, 0xb343a0, 0xc00bd75bc0)
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:2072 +0x205c
honnef.co/go/tools/ssa.(*builder).buildFunction(0xc0095ab5b0, 0xc00ba404e0)
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:2166 +0x2e0
honnef.co/go/tools/ssa.(*builder).buildFuncDecl(0xc0095ab5b0, 0xc002504150, 0xc00bd75bf0)
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:2197 +0xec
honnef.co/go/tools/ssa.(*Package).build(0xc002504150)
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:2314 +0xcb9
honnef.co/go/tools/ssa.(*Package).build-fm()
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:2232 +0x2a
sync.(*Once).Do(0xc002504190, 0xc009e81750)
/home/travis/.gimme/versions/go1.11.2.linux.amd64/src/sync/once.go:44 +0xb3
honnef.co/go/tools/ssa.(*Package).Build(0xc002504150)
/home/travis/gopath/src/honnef.co/go/tools/ssa/builder.go:2232 +0x54
honnef.co/go/tools/internal/passes/buildssa.run(0xc007ded900, 0x26c2ab433, 0xf199c0, 0xc003a120a0, 0x0)
/home/travis/gopath/src/honnef.co/go/tools/internal/passes/buildssa/buildssa.go:70 +0x26c
honnef.co/go/tools/lint.(*Runner).runAnalysisUser(0xc00025c780, 0xc007ded900, 0xc00c15bbd0, 0xc00779c3c0, 0xc000702c48, 0xb, 0xb)
/home/travis/gopath/src/honnef.co/go/tools/lint/runner.go:492 +0x2b7
honnef.co/go/tools/lint.(*Runner).runAnalysis(0xc00025c780, 0xc00c15bbd0, 0x0, 0x0, 0x0, 0x0)
/home/travis/gopath/src/honnef.co/go/tools/lint/runner.go:366 +0x4d6
honnef.co/go/tools/lint.(*Runner).runAnalysisUser(0xc00025c780, 0xc007ded860, 0xc00c15ae60, 0xc00779c360, 0xc000054758, 0x5a, 0x1)
/home/travis/gopath/src/honnef.co/go/tools/lint/runner.go:478 +0xed
honnef.co/go/tools/lint.(*Runner).runAnalysis(0xc00025c780, 0xc00c15ae60, 0x0, 0x0, 0x0, 0x0)
/home/travis/gopath/src/honnef.co/go/tools/lint/runner.go:366 +0x4d6
honnef.co/go/tools/lint.(*Runner).processPkg.func3(0xc00922ced0, 0xc0003a3e60, 0xc00025c780, 0xc0002125b0, 0xc00c15ae60, 0xc00155c000, 0x7e, 0x7e, 0x54)
/home/travis/gopath/src/honnef.co/go/tools/lint/runner.go:897 +0x7a
created by honnef.co/go/tools/lint.(*Runner).processPkg
/home/travis/gopath/src/honnef.co/go/tools/lint/runner.go:892 +0xa0c
make: *** [staticcheck] Error 2
Here is the repo that is running on: https://github.com/libopenstorage/autopilot
In the Makefile, there is a make staticcheck rule which is hitting this.
Thanks, I can reproduce the problem with that. Will fix.
Most helpful comment
Thanks, I can reproduce the problem with that. Will fix.