Closed
Description
nil pointer error in toSourceDiagnostic
gopls version
golang.org/x/tools/gopls@master: 85554d6
Build info
----------
golang.org/x/tools/gopls master
golang.org/x/tools/gopls@(devel)
github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
golang.org/x/mod@v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
golang.org/x/sync@v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sys@v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/text@v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/tools@v0.6.0 => ../
golang.org/x/vuln@v0.0.0-20230110180137-6ad3e3d07815 h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vmU=
honnef.co/go/tools@v0.4.2 h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc=
mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.19.9
go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/Users/bingjia.chen/go/bin"
GOCACHE="/Users/bingjia.chen/Library/Caches/go-build"
GOENV="/Users/bingjia.chen/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/bingjia.chen/go/pkg/mod"
GOOS="darwin"
GOPATH="/Users/bingjia.chen/go"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.9"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cn/yf347khx1k1fh7ctyx6sdjgm0000gy/T/go-build2061136138=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
simplely trigger the error or warn disagnostic
What did you expect to see?
lsp work correctly
What did you see instead?
gopls got detech and killed
Editor and settings
Editor: nvim v0.9.1
Pluigins:ray-x/go.nvim
Lsp Config:
lsp_cfg = {
capabilities = require('cmp_nvim_lsp').default_capabilities(),
handlers = handlers,
settings = {
gopls = {
directoryFilters = {
"-**/protobuf/go/",
"-protobuf/go",
},
analyses = {
shadow = false,
}
}
}
},
Logs
[ERROR][2023-06-21 11:00:35] .../vim/lsp/rpc.lua:734 "rpc" "/Users/bingjia.chen/go/bin/gopls" "stderr" "panic: runtime error: invalid memory address or nil pointer dereference\n[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x100801ebd]\n\ngoroutine 19035 [running]:\ngolang.org/x/tools/gopls/internal/lsp/cache.toSourceDiagnostic(0x0, 0xc021867ab0)\n\t/tmp/tools/gopls/internal/lsp/cache/errors.go:316 +0x7d\ngolang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).Analyze(0x0, {0x100d6f920, 0xc0208a8d20}, 0xc0208a8390, {0xc020880800, 0xc6, 0x0?})\n\t/tmp/tools/gopls/internal/lsp/cache/analysis.go:351 +0xee5\ngolang.org/x/tools/gopls/internal/lsp/source.Analyze({0x100d6f920, 0xc0208a8d20}, {0x100d7c238, 0xc01d867680}, 0xc00098e300?, 0x0)\n\t/tmp/tools/gopls/internal/lsp/source/diagnostics.go:48 +0x255\ngolang.org/x/tools/gopls/internal/lsp.(*Server).diagnosePkgs.func2()\n\t/tmp/tools/gopls/internal/lsp/diagnostics.go:452 +0xc7\ncreated by golang.org/x/tools/gopls/internal/lsp.(*Server).diagnosePkgs\n\t/tmp/tools/gopls/internal/lsp/diagnostics.go:450 +0x31d\n"
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
adonovan commentedon Jun 21, 2023
This seems very closely related to #60551, though I still don't have a good hypothesis for that one.
adonovan commentedon Jun 21, 2023
Actually the explanation for this one is very simple: the enabled set of analyzers is expanded to include all "required" analyzer dependencies, to ensure that the root analyzer set is a superset of the facty set, allowing us to analyze each package with exactly one set. But the expanded set should not be used for the final loop.
Thanks for the prompt and very clear bug report!
gopherbot commentedon Jun 21, 2023
Change https://go.dev/cl/504818 mentions this issue:
gopls/internal/lsp/cache: fix nil panic in analysis toSourceDiagnostic
ccbhj commentedon Jun 23, 2023
Thank you for the fix and reply in such a short time! Great work on gopls btw.
gopls/internal/lsp/cache: fix nil panic in analysis toSourceDiagnostic