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: crash in import organization #40208

Closed
littldr opened this issue Jul 14, 2020 · 4 comments
Closed

x/tools/gopls: crash in import organization #40208

littldr opened this issue Jul 14, 2020 · 4 comments
Assignees
Labels
Milestone

Comments

@littldr
Copy link

@littldr littldr commented Jul 14, 2020

Describe what you observed.

I've installed the extension (and the recommended tools) and opened a go file which contains only the package definition, like this:

package protocol

The gopls server crashed immediately. Adding an empty newline to the file and reloading the editor fixes this error.

Stacktrace

[Info  - 8:51:45 AM] 2020/07/14 08:51:45 go/packages.Load
	snapshot=1
	package_path="command-line-arguments"
	files=[/Users/andi/Workspace/hub/protocol/parser.go]

panic: runtime error: slice bounds out of range [:17] with capacity 16

goroutine 81 [running]:
golang.org/x/tools/internal/lsp/source.importPrefix(0xc0000aa420, 0x10, 0x10, 0xc0004b09a0, 0x0)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/source/format.go:211 +0x2aa
golang.org/x/tools/internal/lsp/source.computeFixEdits(0x1a7a000, 0xc0000df600, 0x1a68220, 0xc00016ffe0, 0xc0004b4740, 0xc0000aa420, 0x10, 0x10, 0xc00043d2c0, 0x0, ...)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/source/format.go:156 +0x5d
golang.org/x/tools/internal/lsp/source.computeImportEdits(0x1a68020, 0xc0002dd1d0, 0x1a7a000, 0xc0000df600, 0x1a68220, 0xc00016ffe0, 0xc0004b4740, 0x0, 0xc0004b0d78, 0xc000032c00, ...)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/source/format.go:112 +0x26d
golang.org/x/tools/internal/lsp/source.AllImportsFixes.func1(0xc0004b4740, 0xc0004b4740, 0xc0002dd1d0)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/source/format.go:84 +0xeb
golang.org/x/tools/internal/lsp/cache.(*View).RunProcessEnvFunc(0xc0000df600, 0x1a68020, 0xc0002dd1d0, 0xc000097a90, 0x0, 0x0)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/cache/view.go:421 +0x197
golang.org/x/tools/internal/lsp/source.AllImportsFixes(0x1a68020, 0xc0002dd1d0, 0x1a7b060, 0xc000109880, 0x1a6be20, 0xc000426060, 0xc000379800, 0xc000320870, 0x5, 0x5, ...)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/source/format.go:83 +0x2d5
golang.org/x/tools/internal/lsp.(*Server).codeAction(0xc00030f300, 0x1a67f60, 0xc000400880, 0xc000109b00, 0xc000109b00, 0x0, 0x0, 0x0, 0xc0004956b0)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/code_action.go:82 +0x158b
golang.org/x/tools/internal/lsp.(*Server).CodeAction(0xc00030f300, 0x1a67f60, 0xc000400880, 0xc000109b00, 0xc000109b00, 0x0, 0x0, 0x1a665e0, 0xc0000ba120)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/server_gen.go:12 +0x4d
golang.org/x/tools/internal/lsp/protocol.serverDispatch(0x1a67f60, 0xc000400880, 0x1a823e0, 0xc00030f300, 0xc0002dca50, 0x1a681a0, 0xc000400800, 0x0, 0x0, 0xbfbb73606c136e98)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/protocol/tsserver.go:311 +0x1c8a
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1(0x1a67f60, 0xc000400880, 0xc0002dca50, 0x1a681a0, 0xc000400800, 0x0, 0x0)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/protocol/protocol.go:62 +0xc0
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1(0x1a67f60, 0xc000400880, 0xc0002dca50, 0x1a681a0, 0xc000400800, 0x0, 0x0)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/lsprpc/lsprpc.go:509 +0x40e
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1(0x1a67f60, 0xc000400880, 0xc000438140, 0x1a681a0, 0xc000400800, 0x0, 0x0)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/jsonrpc2/handler.go:35 +0xd3
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0xc000312f60, 0xc000425a70, 0xc0004060b0, 0x1a67f60, 0xc000400880, 0xc000438140, 0x1a681a0, 0xc000400800)
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/jsonrpc2/handler.go:103 +0x86
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	/Users/andi/.asdf/installs/golang/1.14/packages/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/jsonrpc2/handler.go:100 +0x171
[Error - 8:51:45 AM] Connection to server got closed. Server will not be restarted.
[Error - 8:51:45 AM] Request textDocument/codeAction failed.
Error: Connection got disposed.
	at Object.dispose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:904:25)
	at Object.dispose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:74:35)
	at LanguageClient.handleConnectionClosed (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2309:42)
	at LanguageClient.handleConnectionClosed (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/main.js:155:15)
	at closeHandler (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2296:18)
	at CallbackList.invoke (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at closeHandler (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:240:26)
	at CallbackList.invoke (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at StreamMessageReader.fireClose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
	at Socket.<anonymous> (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
	at Socket.emit (events.js:208:15)
	at Pipe.<anonymous> (net.js:588:12)
[Error - 8:51:45 AM] Request textDocument/documentLink failed.
Error: Connection got disposed.
	at Object.dispose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:904:25)
	at Object.dispose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:74:35)
	at LanguageClient.handleConnectionClosed (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2309:42)
	at LanguageClient.handleConnectionClosed (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/main.js:155:15)
	at closeHandler (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2296:18)
	at CallbackList.invoke (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at closeHandler (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:240:26)
	at CallbackList.invoke (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at StreamMessageReader.fireClose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
	at Socket.<anonymous> (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
	at Socket.emit (events.js:208:15)
	at Pipe.<anonymous> (net.js:588:12)
[Error - 8:51:45 AM] Request textDocument/foldingRange failed.
Error: Connection got disposed.
	at Object.dispose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:904:25)
	at Object.dispose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:74:35)
	at LanguageClient.handleConnectionClosed (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2309:42)
	at LanguageClient.handleConnectionClosed (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/main.js:155:15)
	at closeHandler (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2296:18)
	at CallbackList.invoke (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at closeHandler (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:240:26)
	at CallbackList.invoke (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at StreamMessageReader.fireClose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
	at Socket.<anonymous> (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
	at Socket.emit (events.js:208:15)
	at Pipe.<anonymous> (net.js:588:12)
[Error - 8:51:45 AM] Request textDocument/codeLens failed.
Error: Connection got disposed.
	at Object.dispose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:904:25)
	at Object.dispose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:74:35)
	at LanguageClient.handleConnectionClosed (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2309:42)
	at LanguageClient.handleConnectionClosed (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/main.js:155:15)
	at closeHandler (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2296:18)
	at CallbackList.invoke (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at closeHandler (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:240:26)
	at CallbackList.invoke (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at StreamMessageReader.fireClose (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
	at Socket.<anonymous> (/Users/andi/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
	at Socket.emit (events.js:208:15)
	at Pipe.<anonymous> (net.js:588:12)

OPTIONAL: If you would like to share more information, you can attach your complete gopls logs.

NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE.
DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.

<OPTIONAL: ATTACH LOGS HERE>

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jul 14, 2020

Thank you for the report!

/cc @pjweinbgo @heschik

@stamblerre stamblerre changed the title gopls: automated issue report (crash) x/tools/gopls: crash in imports Jul 14, 2020
@stamblerre stamblerre changed the title x/tools/gopls: crash in imports x/tools/gopls: crash in import organization Jul 14, 2020
@stamblerre stamblerre transferred this issue from golang/vscode-go Jul 14, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jul 14, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.4 Jul 14, 2020
@pjweinb
Copy link

@pjweinb pjweinb commented Jul 14, 2020

off by one. (token.Pos is 1-based) CL in progress

Thank you for the report.

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 14, 2020

Change https://golang.org/cl/242638 mentions this issue: internal/lsp: avoid panic caused by assuming file ends with newline

@pjweinb
Copy link

@pjweinb pjweinb commented Jul 14, 2020

change 242638 fixes it.

@pjweinb pjweinb self-assigned this Jul 14, 2020
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
4 participants
You can’t perform that action at this time.