Skip to content

x/tools/gopls: gopls crash with vscode-go in remote development #39789

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

Closed
wdcui opened this issue Jun 23, 2020 · 5 comments
Closed

x/tools/gopls: gopls crash with vscode-go in remote development #39789

wdcui opened this issue Jun 23, 2020 · 5 comments
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. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@wdcui
Copy link

wdcui commented Jun 23, 2020

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

$ go version

go1.14.4

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Ubuntu on WSL 2.
gopls-error.txt

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/wdcui/.cache/go-build"
GOENV="/home/wdcui/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/wdcui/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/wdcui/repo/VMEnclaves/cvm-runtime/go.mod"
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-build196659605=/tmp/go-build -gno-record-gcc-switches"

What did you do?

What did you expect to see?

What did you see instead?

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jun 23, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 23, 2020
@golang golang deleted a comment from gopherbot Jun 23, 2020
@stamblerre
Copy link
Contributor

Thanks for the report! Pasting the stack trace here so it's easier to find:

panic: parse "file://wsl%24/Ubuntu/home/wdcui/repo/VMEnclaves/cvm-runtime": invalid URL escape "%24"

goroutine 99 [running]:
golang.org/x/tools/internal/span.URI.Filename(0xc000223840, 0x3b, 0x5, 0xe)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/span/uri.go:32 +0xcd
golang.org/x/tools/internal/lsp/cache.(*view).setBuildInformation(0xc0000f82c0, 0xe38620, 0xc000428c90, 0xc000223840, 0x3b, 0xc0000f0000, 0x3c, 0x70, 0x5f5e101, 0x0, ...)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/lsp/cache/view.go:616 +0x62
golang.org/x/tools/internal/lsp/cache.(*Session).createView(0xc0000a4c60, 0xe38620, 0xc000428c90, 0xc0003cef50, 0xb, 0xc000223840, 0x3b, 0x4000000000000000, 0x10101, 0xc0003ceea8, ...)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/lsp/cache/session.go:145 +0x4fc
golang.org/x/tools/internal/lsp/cache.(*Session).NewView(0xc0000a4c60, 0xe38620, 0xc000428c90, 0xc0003cef50, 0xb, 0xc000223840, 0x3b, 0x4000000000000000, 0x10101, 0xc0003ceea8, ...)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/lsp/cache/session.go:95 +0x132
golang.org/x/tools/internal/lsp.(*Server).addView(0xc000099380, 0xe38620, 0xc000428c90, 0xc0003cef50, 0xb, 0xc000223840, 0x3b, 0x0, 0x0, 0x0, ...)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/lsp/workspace.go:42 +0x1eb
golang.org/x/tools/internal/lsp.(*Server).addFolders(0xc000099380, 0xe38620, 0xc000428c90, 0xc000214e00, 0x1, 0x4)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/lsp/general.go:190 +0x18b
golang.org/x/tools/internal/lsp.(*Server).initialized(0xc000099380, 0xe38620, 0xc000428c90, 0x1390e70, 0x0, 0x0)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/lsp/general.go:178 +0x3ab
golang.org/x/tools/internal/lsp.(*Server).Initialized(0xc000099380, 0xe38620, 0xc000428c90, 0x1390e70, 0x1390e70, 0x0)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/lsp/server_gen.go:112 +0x50
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1(0xe38620, 0xc000428c90, 0xc0003e9380, 0x275142f0, 0xc000428c30, 0x0, 0x0)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/lsp/protocol/tsserver.go:98 +0x7bf
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1(0xe38620, 0xc000428c90, 0xc0003e9380, 0x275142f0, 0xc000428c30, 0x0, 0x0)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/lsp/lsprpc/lsprpc.go:531 +0x558
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1(0xe38620, 0xc000428c90, 0xc0000c9ec0, 0x275142f0, 0xc000428c30, 0x0, 0x0)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/jsonrpc2/handler.go:35 +0xda
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0xc000094c60, 0xc0004290b0, 0xc00008b7d0, 0xe38620, 0xc000428c90, 0xc0000c9ec0, 0x275142f0, 0xc000428c30)
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/jsonrpc2/handler.go:103 +0x8d
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	C:/Users/wdcui/go/pkg/mod/golang.org/x/[email protected]/internal/jsonrpc2/handler.go:100 +0x178
[Error - 11:39:32 AM] Connection to server got closed. Server will not be restarted.

/cc @heschik

@wdcui
Copy link
Author

wdcui commented Jun 23, 2020

I spent some time poking around this bug.

The path to the WSL folder has "wsl$". Somewhere in the callstack, it's converted to %24. However, net/url doesn't think "$" should be escaped. This inconsistency caused net/url to return an error and then span.URI.FileName calls panic.

I wasn't able to figure out what code converts "$" to "%24".

@stamblerre
Copy link
Contributor

Thanks for looking into this! VS Code seems to over-escape characters in a number of cases, and I believe we already ran into this with %. I believe our code has changed a lot since we fixed that case, so I'll let @heschik suggest what the right fix is.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Jun 24, 2020
@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 24, 2020
@heschi
Copy link
Contributor

heschi commented Jun 24, 2020

The file URL is invalid in a new way: it only has two slashes. It should be file:///wsl%24/Ubuntu/home/wdcui/repo/VMEnclaves/cvm-runtime.

I guess we can try to fix up this too.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/239743 mentions this issue: internal/span: handle file URLs with two slashes

@stamblerre stamblerre modified the milestones: gopls/v0.5.0, gopls/v0.4.4 Jul 9, 2020
@golang golang locked and limited conversation to collaborators Jul 9, 2021
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. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants