-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: panic on filenames containing % #36999
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
Comments
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
Thanks for filing this issue - I am able to reproduce and will investigate. @jayconrod: Does the go command support leading % in filenames? I believe that is invalid. |
|
Change https://golang.org/cl/217542 mentions this issue: |
I did a little more digging. There are some problems with the way filenames are being URL-encoded. I've attached a patch that adds a testcase for this, and some updates to make the test pass. The problems are:
|
Sorry, I've committed a cretinous error and given you a backwards patch. Here's the same patch with the diff params in the right order. I rebuilt |
Change https://golang.org/cl/217599 mentions this issue: |
Thank you for investigating and for figuring out the issue. We came to a similar conclusion around the same time :) Just mailed the above CL, which should hopefully address the issue. |
Change https://golang.org/cl/217639 mentions this issue: |
This has been cherry-picked onto |
We had previously worked around a VS Code URI bug by unescaping URIs. This is incorrect, so stop doing it and then add a specific workaround just for that one bug. Fixes golang/go#36999 Change-Id: I92f1a5f71749af7a6b1020eee1272586515f7084 Reviewed-on: https://go-review.googlesource.com/c/tools/+/217599 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> (cherry picked from commit 35ac94b) Reviewed-on: https://go-review.googlesource.com/c/tools/+/217639
Thank you for the quick fix! :) |
What did you do?
At some point, someone added a directory to our source tree that contained '%' characters.
This causes gopls to crash (the crash seems to be a recent development, since the directory has been there for about a year.)
You can reproduce this easily, at least on a Mac. I haven't tried this on Linux but I don't see why it wouldn't crash there too. Steps:
~/src/%crash_pls%
~/src/%crash_pls%/main.go
code ~/src/%crash_pls%
What did you expect to see?
'%' is a valid character in file paths, so gopls should have worked.
What did you see instead?
The editor reports that gopls has crashed multiple times and won't be restarted.
Stack trace:
goroutine 50 [running]:
golang.org/x/tools/internal/span.URI.Filename(...)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/span/uri.go:28
golang.org/x/tools/internal/lsp/cache.(*view).getGoEnv(0xc00034c000, 0x1a55100, 0xc000299890, 0xc0001a6480, 0x46, 0x46, 0xc0003cce50, 0x100e194, 0xc00033a0a0, 0xa0)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/lsp/cache/view.go:730 +0x77c
golang.org/x/tools/internal/lsp/cache.(*view).setBuildInformation(0xc00034c000, 0x1a55100, 0xc000299890, 0xc0001ca270, 0x29, 0xc0001a6480, 0x46, 0x46, 0x0, 0x0, ...)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/lsp/cache/view.go:622 +0x8f
golang.org/x/tools/internal/lsp/cache.(*session).createView(0xc0000e3b80, 0x1a55100, 0xc000299890, 0xc0002de080, 0xb, 0xc0001ca270, 0x29, 0x4000000000000000, 0x10101, 0xc00016ffd8, ...)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/lsp/cache/session.go:109 +0x4c9
golang.org/x/tools/internal/lsp/cache.(*session).NewView(0xc0000e3b80, 0x1a55100, 0xc000299890, 0xc0002de080, 0xb, 0xc0001ca270, 0x29, 0x4000000000000000, 0x10101, 0xc00016ffd8, ...)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/lsp/cache/session.go:62 +0x13d
golang.org/x/tools/internal/lsp.(*Server).addView(0xc000244a80, 0x1a55100, 0xc000299890, 0xc0002de080, 0xb, 0xc0001ca270, 0x29, 0x8bee37f, 0x1f8a640, 0xc000338000, ...)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/lsp/workspace.go:42 +0x1fe
golang.org/x/tools/internal/lsp.(*Server).addFolders(0xc000244a80, 0x1a55100, 0xc000299890, 0xc00018ec80, 0x1, 0x4)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/lsp/general.go:168 +0x1bc
golang.org/x/tools/internal/lsp.(*Server).initialized(0xc000244a80, 0x1a55100, 0xc000299890, 0x1fa76d0, 0x0, 0x0)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/lsp/general.go:156 +0x263
golang.org/x/tools/internal/lsp.(*Server).Initialized(0xc000244a80, 0x1a55100, 0xc000299890, 0x1fa76d0, 0x1fa76d0, 0x0)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/lsp/server_gen.go:112 +0x49
golang.org/x/tools/internal/lsp/protocol.serverHandler.Deliver(0x1a73100, 0xc000244a80, 0x1a55100, 0xc000299890, 0xc0002b6180, 0xc000299800, 0xc00023e8c0)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/lsp/protocol/tsserver.go:110 +0x970
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc00003ad20, 0xc0002b6180, 0xc000296780, 0x1a55100, 0xc000299890, 0x0, 0x0, 0xc000247270)
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/jsonrpc2/jsonrpc2.go:370 +0x170
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
/Users/geoffhickey/pkg/mod/golang.org/x/[email protected]/internal/jsonrpc2/jsonrpc2.go:354 +0x877
[Error - 2:34:35 PM] Connection to server got closed. Server will not be restarted.
[Error - 2:34:35 PM] Request textDocument/documentSymbol failed.
Error: Connection got disposed.
at Object.dispose (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/main.js:876:25)
at Object.dispose (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-languageclient/lib/client.js:71:35)
at LanguageClient.handleConnectionClosed (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-languageclient/lib/client.js:2153:42)
at LanguageClient.handleConnectionClosed (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-languageclient/lib/main.js:151:15)
at closeHandler (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-languageclient/lib/client.js:2140:18)
at CallbackList.invoke (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
at Emitter.fire (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/events.js:120:36)
at closeHandler (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/main.js:226:26)
at CallbackList.invoke (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
at Emitter.fire (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/events.js:120:36)
at StreamMessageReader.fireClose (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
at Socket. (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
at Socket.emit (events.js:205:15)
at Pipe. (net.js:586:12)
[Error - 2:34:35 PM] Request textDocument/documentLink failed.
Error: Connection got disposed.
at Object.dispose (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/main.js:876:25)
at Object.dispose (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-languageclient/lib/client.js:71:35)
at LanguageClient.handleConnectionClosed (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-languageclient/lib/client.js:2153:42)
at LanguageClient.handleConnectionClosed (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-languageclient/lib/main.js:151:15)
at closeHandler (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-languageclient/lib/client.js:2140:18)
at CallbackList.invoke (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
at Emitter.fire (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/events.js:120:36)
at closeHandler (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/main.js:226:26)
at CallbackList.invoke (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
at Emitter.fire (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/events.js:120:36)
at StreamMessageReader.fireClose (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
at Socket. (/Users/geoffhickey/.vscode/extensions/ms-vscode.go-0.13.0/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
at Socket.emit (events.js:205:15)
at Pipe. (net.js:586:12)
Build info
Go info
The text was updated successfully, but these errors were encountered: