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: gopls crash with vscode-go in remote development #39789

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

Comments

@wdcui
Copy link

@wdcui 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 this to the Unreleased milestone Jun 23, 2020
@golang golang deleted a comment from gopherbot Jun 23, 2020
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 23, 2020

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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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/tools@v0.0.0-20200513154647-78b527d18275/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 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

@stamblerre stamblerre commented Jun 24, 2020

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.

@heschik
Copy link
Contributor

@heschik heschik 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

@gopherbot gopherbot commented Jun 24, 2020

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

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.