Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: panic because of nil pointer in cache.fileWasSaved #37687

Closed
myitcv opened this issue Mar 5, 2020 · 2 comments
Closed

x/tools/gopls: panic because of nil pointer in cache.fileWasSaved #37687

myitcv opened this issue Mar 5, 2020 · 2 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@myitcv
Copy link
Member

myitcv commented Mar 5, 2020

What version of Go are you using (go version)?

$ go version
go version devel +972df38445 Tue Mar 3 02:34:32 2020 +0000 linux/amd64
$ go list -m golang.org/x/tools
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb
$ go list -m golang.org/x/tools/gopls
golang.org/x/tools/gopls v0.1.8-0.20200304193943-95d2e580d8eb

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/gos"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/myitcv/gostuff/src/github.com/myitcv/govim/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-build717381237=/tmp/go-build -gno-record-gcc-switches"

What did you do?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0xb050a7]

goroutine 99 [running]:
golang.org/x/tools/internal/lsp/cache.fileWasSaved(...)
 /home/runner/gopath/pkg/mod/golang.org/x/tools@v0.0.0-20200304193943-95d2e580d8eb/internal/lsp/cache/snapshot.go:800
golang.org/x/tools/internal/lsp/cache.(*snapshot).clone(0xc0001d7ce0, 0xe53680, 0xc000158150, 0xc00014e7e0, 0x0)
 /home/runner/gopath/pkg/mod/golang.org/x/tools@v0.0.0-20200304193943-95d2e580d8eb/internal/lsp/cache/snapshot.go:689 +0xea7
golang.org/x/tools/internal/lsp/cache.(*view).invalidateContent(0xc0001bb680, 0xe53000, 0xc000090ea0, 0xc00014e7e0, 0x0, 0x0)
 /home/runner/gopath/pkg/mod/golang.org/x/tools@v0.0.0-20200304193943-95d2e580d8eb/internal/lsp/cache/view.go:570 +0x152
golang.org/x/tools/internal/lsp/cache.(*Session).DidModifyFiles(0xc000224840, 0xe53000, 0xc000090ea0, 0xc00015caa0, 0x1, 0x1, 0x199, 0x40, 0x0, 0x20300000000000, ...)
 /home/runner/gopath/pkg/mod/golang.org/x/tools@v0.0.0-20200304193943-95d2e580d8eb/internal/lsp/cache/session.go:325 +0x2aa
golang.org/x/tools/internal/lsp.(*Server).didModifyFiles(0xc000229900, 0xe53000, 0xc000090ea0, 0xc00015caa0, 0x1, 0x1, 0x0, 0x1, 0x0)
 /home/runner/gopath/pkg/mod/golang.org/x/tools@v0.0.0-20200304193943-95d2e580d8eb/internal/lsp/text_synchronization.go:172 +0x8d
golang.org/x/tools/internal/lsp.(*Server).didChangeWatchedFiles(0xc000229900, 0xe53000, 0xc000090ea0, 0xc000168000, 0x0, 0xc0002804d0)
 /home/runner/gopath/pkg/mod/golang.org/x/tools@v0.0.0-20200304193943-95d2e580d8eb/internal/lsp/text_synchronization.go:99 +0x26a
golang.org/x/tools/internal/lsp.(*Server).DidChangeWatchedFiles(0xc000229900, 0xe53000, 0xc000090ea0, 0xc000168000, 0xc000168000, 0x0)
 /home/runner/gopath/pkg/mod/golang.org/x/tools@v0.0.0-20200304193943-95d2e580d8eb/internal/lsp/server_gen.go:44 +0x49
golang.org/x/tools/internal/lsp/protocol.serverHandler.Deliver(0xe70d40, 0xc000229900, 0xe53000, 0xc000090ea0, 0xc000032100, 0x0, 0x0)
 /home/runner/gopath/pkg/mod/golang.org/x/tools@v0.0.0-20200304193943-95d2e580d8eb/internal/lsp/protocol/tsserver.go:185 +0x60be
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc00003f7a0, 0xc000032100, 0xc0002636e0, 0xe53000, 0xc000090ea0, 0x0, 0x0, 0xc000042420)
 /home/runner/gopath/pkg/mod/golang.org/x/tools@v0.0.0-20200304193943-95d2e580d8eb/internal/jsonrpc2/jsonrpc2.go:372 +0x170
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
 /home/runner/gopath/pkg/mod/golang.org/x/tools@v0.0.0-20200304193943-95d2e580d8eb/internal/jsonrpc2/jsonrpc2.go:356 +0x84d

We also see quite a lot of noise on gopls stderr, like:

2020/03/05 09:28:57 Not a method...
2020/03/05 09:28:57 Not a method...
2020/03/05 09:28:57 Not a method... status.code="OK"

What did you expect to see?

No panic. Although the panic isn't 100% reproducible, we see it ~50% of the time on CI.

What did you see instead?

As above.


cc @stamblerre @findleyr

FYI @leitzler

@myitcv myitcv added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. labels Mar 5, 2020
@gopherbot gopherbot added this to the Unreleased milestone Mar 5, 2020
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Mar 5, 2020
@gopherbot
Copy link

Change https://golang.org/cl/222217 mentions this issue: internal/lsp/cache: fix NPE in fileWasSaved

@findleyr
Copy link
Contributor

findleyr commented Mar 5, 2020

Thanks for reporting! Fix incoming.

I filed #37696 for the log spam, which is unrelated.

@golang golang locked and limited conversation to collaborators Mar 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants