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/internal/lsp: crash when working with module replacements #30797

Closed
marwan-at-work opened this issue Mar 13, 2019 · 4 comments
Closed
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.
Milestone

Comments

@marwan-at-work
Copy link
Contributor

Summary

The server seems to crash and VSCode stops trying to use it when the reproduction steps below happen.

It's also worth mentioning that this might be an upstream issue with either go/packages or go modules because without gopls, the same issue still happens minus the crash since there's no LSP.

Info

  • Go version: 1.12 darwin
  • Editor: VSCode
  • gopls version: e65039

reproduce

~ mkdir temp
~ cd temp
~ go mod init temp
~ go get golang.org/x/oauth2
~ go mod edit -replace=golang.org/x/oauth2=github.com/wlhee/oauth2@master
- go get
~ touch main.go

In main.go, paste the following:

package main

import "golang.org/x/oauth2/google"

func main() {
	google.JWTConfigFromJSON(nil)
}

Then, cmd+click on the function JWTConfigFromJSON, which should take you to the replaced file in $GOPATH/pkg.

There, try clicking around or hovering over any symbol and you should see the crash sign as attached below:

Screen Shot 2019-03-13 at 2 12 35 AM

@gopherbot gopherbot added this to the Unreleased milestone Mar 13, 2019
@marwan-at-work marwan-at-work added the gopls Issues related to the Go language server, gopls. label Mar 13, 2019
@sashker
Copy link

sashker commented Apr 7, 2019

+1
For my situation, it's just enough to open any file with go-code in it and the server immediately crashes

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 12, 2019
@bcmills
Copy link
Contributor

bcmills commented Apr 12, 2019

CC @stamblerre

@kidlj
Copy link

kidlj commented Apr 16, 2019

I encountered gopls crashes too using with vscode.

The gopls log says:

[Error - 3:00:13 PM] Request textDocument/codeAction failed.
Error: Connection got disposed.
	at Object.dispose (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-jsonrpc/lib/main.js:876:25)
	at Object.dispose (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-languageclient/lib/client.js:57:35)
	at LanguageClient.handleConnectionClosed (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-languageclient/lib/client.js:2036:42)
	at LanguageClient.handleConnectionClosed (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-languageclient/lib/main.js:127:15)
	at closeHandler (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-languageclient/lib/client.js:2023:18)
	at CallbackList.invoke (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-jsonrpc/lib/events.js:120:36)
	at closeHandler (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-jsonrpc/lib/main.js:226:26)
	at CallbackList.invoke (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-jsonrpc/lib/events.js:120:36)
	at StreamMessageReader.fireClose (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
	at Socket.listen.readable.on (/Users/mellon/.vscode/extensions/ms-vscode.go-0.9.3-beta.7/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
	at Socket.emit (events.js:187:15)
	at Pipe.Socket._destroy._handle.close [as _onclose] (net.js:596:12)
panic: interface conversion: ast.Expr is *ast.Ident, not *ast.StructType

goroutine 34 [running]:
golang.org/x/tools/internal/lsp/source.typeSymbol(0xc0014dba40, 0x14d0040, 0xc004cbb720, 0xc00009c800, 0xc00762fbc0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/mellon/go/src/golang.org/x/tools/internal/lsp/source/symbols.go:177 +0x696
golang.org/x/tools/internal/lsp/source.DocumentSymbols(0x14c9c80, 0xc0000d6d80, 0x14cc180, 0xc00022c320, 0xc00025c030, 0x2d, 0x14cc180)
	/Users/mellon/go/src/golang.org/x/tools/internal/lsp/source/symbols.go:71 +0xc0b
golang.org/x/tools/internal/lsp.(*Server).DocumentSymbol(0xc0001803f0, 0x14c9c80, 0xc0000d6d80, 0xc0001b4290, 0xc0001b4290, 0x0, 0x0, 0x0, 0x0)
	/Users/mellon/go/src/golang.org/x/tools/internal/lsp/server.go:505 +0x14b
golang.org/x/tools/internal/lsp/protocol.serverHandler.func1(0x14c9c80, 0xc0000d6d80, 0xc000180460, 0xc0000b6cc0)
	/Users/mellon/go/src/golang.org/x/tools/internal/lsp/protocol/server.go:323 +0x4260
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc0000b4900, 0xc000180460)
	/Users/mellon/go/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:276 +0xda
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
	/Users/mellon/go/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:270 +0xba
[Info  - 3:00:14 PM] Connection to server got closed. Server will restart.
[Error - 3:00:14 PM] Request textDocument/documentSymbol failed.

@ianthehat
Copy link

ianthehat commented Apr 16, 2019

This was fixed by cl/171861

@golang golang locked and limited conversation to collaborators Apr 15, 2020
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.
Projects
None yet
Development

No branches or pull requests

6 participants