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: neovim vim.lsp.buf.server_ready() crashes gopls server #43462

Closed
pohzipohzi opened this issue Jan 2, 2021 · 1 comment
Closed

x/tools/gopls: neovim vim.lsp.buf.server_ready() crashes gopls server #43462

pohzipohzi opened this issue Jan 2, 2021 · 1 comment

Comments

@pohzipohzi
Copy link

@pohzipohzi pohzipohzi commented Jan 2, 2021

What did you do?

Running neovim's vim.lsp.buf.server_ready() crashes the gopls server. The payload appears to send parameters of unexpected type, causing a panic to happen during interface assertion for nonstandard requests

To reproduce, we can start neovim with this minimal config

call plug#begin()
Plug 'neovim/nvim-lspconfig'
call plug#end()
lua require'lspconfig'.gopls.setup{}

edit a .go file, and run :echo luaeval('vim.lsp.buf.server_ready()'). The result should return true and gopls should crash. We can see Neovim's debug log by running

:tabe `=luaeval('vim.lsp.get_log_path()')`

What did you expect to see?

The server should not panic and should instead return an error

What did you see instead?

Here's the stack trace from neovim:

[ ERROR ] 2021-01-02T07:00:30+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ]	"rpc"	"gopls"	"stderr"	"panic: interface conversion: interface {} is []interface {}, not map[string]interface {}\n\ngoroutine 7457 [running]:\ngolang.org/x/tools/internal/lsp.(*Server).nonstandardRequest(0xc00010c460, 0xf26b60, 0xc008ee8270, 0xc008cc80a0, 0xf, 0xc99940, 0xc0052262a0, 0x0, 0x0, 0x0, ...)\n\t/home/poh/oss/tools/internal/lsp/server.go:118 +0x745\ngolang.org/x/tools/internal/lsp.(*Server).NonstandardRequest(0xc00010c460, 0xf26b60, 0xc008ee8270, 0xc008cc80a0, 0xf, 0xc99940, 0xc0052262a0, 0xc0052e2000, 0x0, 0x0, ...)\n\t/home/poh/oss/tools/internal/lsp/server_gen.go:124 +0x77"
[ ERROR ] 2021-01-02T07:00:30+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ]	"rpc"	"gopls"	"stderr"	"\ngolang.org/x/tools/internal/lsp/protocol.ServerHandler.func1(0xf26b60, 0xc008ee8270, 0xc00901a000, 0x7f62703ced40, 0xc008ee80f0, 0x58695eec6, 0x138fa20)\n\t/home/poh/oss/tools/internal/lsp/protocol/protocol.go:74 +0x24a\ngolang.org/x/tools/internal/lsp/lsprpc.handshaker.func1(0xf26b60, 0xc008ee8270, 0xc00901a000, 0x7f62703ced40, 0xc008ee80f0, 0x0, 0x0)\n\t/home/poh/oss/tools/internal/lsp/lsprpc/lsprpc.go:559 +0x452\ngolang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1(0xf26b60, 0xc008ee8270, 0xc0052923a0, 0x7f62703ced40, 0xc008ee80f0, 0xc003447fb0, 0x1)\n\t/home/poh/oss/tools/internal/jsonrpc2/handler.go:35 +0xcf\ngolang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0xc00020c240, 0xc008ee8de0, 0xc000756120, 0xf26b60, 0xc008ee8270, 0xc0052923a0, 0x7f62703ced40, 0xc008ee80f0)\n\t/home/poh/oss/tools/internal/jsonrpc2/handler.go:103 +0x86\ncreated by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1\n\t/home/poh/oss/tools/internal/jsonrpc2/handler.go:100 +0x173\n"

Build info

I am on commit 63754364767c38e3e7b8aa74d2e3b2342e49ee76

golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@(devel)
@gopherbot
Copy link

@gopherbot gopherbot commented Jan 2, 2021

Change https://golang.org/cl/281092 mentions this issue: internal/lsp: avoid panic during interface assertion

gopherbot pushed a commit to golang/tools that referenced this issue Jan 11, 2021
This change fixes a panic in the non-standard request.

Fixes golang/go#43462

Change-Id: I216a56f96ca6159cb9b102183ba3a3eddd186889
GitHub-Last-Rev: 992e818
GitHub-Pull-Request: #265
Reviewed-on: https://go-review.googlesource.com/c/tools/+/281092
Reviewed-by: Peter Weinberger <pjw@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
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.

2 participants