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: invalid memory address or nil pointer dereference in IdentifierInfo.Hover #44326

Closed
pohly opened this issue Feb 17, 2021 · 2 comments
Closed

Comments

@pohly
Copy link

@pohly pohly commented Feb 17, 2021

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

$ go version
go version go1.15.7 linux/amd64
$ gopls version
golang.org/x/tools/gopls v0.6.5
    golang.org/x/tools/gopls@v0.6.5 h1:kLt9rD/dWtVdvc8LmdcxagDFih6zxYXREpKSYYZu5KE=

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=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pohly/.cache/go-build"
GOENV="/home/pohly/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/nvme/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/nvme/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/nvme/gopath/go-1.15.7"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/nvme/gopath/go-1.15.7/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build348293716=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I configured emacs to use gopls in lsp-mode, with gopls running remote through tramp. I opened one Go source file and started moving the cursor through it.

More specifically, the source code location where it crashed was one of these lines:
https://github.com/intel/pmem-csi/blob/a4218ed04b213c5604a0a65f796438b45db39992/pkg/pmem-csi-driver/main.go#L32-L59

Stepping through it line-by-line triggers it reliably.

What did you expect to see?

No errors.

What did you see instead?

Emacs reports: Server gopls-remote:19535 exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n)

From /tmp/gopls-remote-5-stderr (stderr of gopls when invoked through emacs/tramp):

...
[Trace - 10:50:45 AM] Sending request 'textDocument/hover - (63)'.
Params: {"textDocument":{"uri":"file:///nvme/gopath/src/github.com/intel/pmem-csi/pkg/pmem-csi-driver/main.go"},"position":{"line":40,"character":0}}

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

goroutine 18 [running]:
golang.org/x/tools/internal/lsp/source.(*IdentifierInfo).Hover(0x0, 0x0, 0x85d800, 0xc0001fe090, 0x85e700, 0xc0001be0a0)
        golang.org/x/tools/internal/lsp/source/definition.go:50 +0x76
golang.org/x/tools/internal/lsp.(*server).Hover(0xc00012a600, 0x85e380, 0xc023396600, 0xc023398c20, 0xc023398c20, 0x0, 0x0)
        golang.org/x/tools/internal/lsp/server.go:225 +0x182
golang.org/x/tools/internal/lsp/protocol.serverHandler.func1(0x85e380, 0xc023396600, 0xc0001babd0, 0xc023398be0)
        golang.org/x/tools/internal/lsp/protocol/server.go:211 +0xd62
golang.org/x/tools/internal/jsonrpc2.(*Conn).run(0xc0001babd0, 0x85e3c0, 0xc0000180b8, 0xc00007a7c8, 0x605b13)
        golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:327 +0x5c8
golang.org/x/tools/internal/jsonrpc2.NewConn.func4(0xc0001babd0, 0x85e3c0, 0xc0000180b8)
        golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:107 +0x3f
created by golang.org/x/tools/internal/jsonrpc2.NewConn
        golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:106 +0x187
@gopherbot gopherbot added this to the Unreleased milestone Feb 17, 2021
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Feb 17, 2021

@pohly: Is it possible that Emacs is using a different version of gopls than the one you used to report gopls version? The file golang.org/x/tools/internal/lsp/source/definition.go no longer exists, and it has been deleted for some time, so it's definitely not part of gopls/v0.6.5. If you look higher up in your gopls logs, you should see a version reported in the initialization requests.

@pohly
Copy link
Author

@pohly pohly commented Feb 17, 2021

Indeed, there was a /usr/bin/gopls that must have been picked up accidentally when starting it through ssh/tramp. I removed that and now the expected version runs.

However, now emacs locks up. But that's a different issue and probably not related to gopls.

@pohly pohly closed this Feb 17, 2021
@stamblerre stamblerre removed this from the gopls/unplanned milestone Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants