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: panics on master when attempting to jump to a definition in a module not in a loaded workspace #37045

Closed
ilanpillemer opened this issue Feb 5, 2020 · 4 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ilanpillemer
Copy link

ilanpillemer commented Feb 5, 2020

Please answer these questions before submitting your issue. Thanks!

What did you do?

attempting to follow a definition to a function in a module not in a loaded workspace

What did you expect to see?

either for it to work, or not to work (maybe with an info message if not working)

What did you see instead?

gopl crashes. I have enabled -rpc.trace.

the immediate error is 2020/02/05 14:25:03 io: read/write on closed pipe

example 1

[Trace - 10:55:37.331 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/02/05 10:55:37 go/packages.Load\n\tsnapshot = 0\n\tpackage = command-line-arguments\n\tfiles = [/Users/ilanpillemer/Repos/bxbdigital/bx-rs/relationalsystem/relationalsystem.go]"}

panic: unexpected parse mode for command-line-arguments
goroutine 11981 [running]:
golang.org/x/tools/internal/lsp/cache.expectMode(...)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/cache/snapshot.go:376
golang.org/x/tools/internal/lsp/cache.(*snapshot).packageHandle(0xc0002c0ea0, 0x1a5baa0, 0xc00c1918c0, 0xc0063d1080, 0x16, 0xc000994300, 0xc007336700, 0xc000a4aee8)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/cache/snapshot.go:113 +0x59d
golang.org/x/tools/internal/lsp/cache.(*snapshot).load(0xc0002c0ea0, 0x1a5baa0, 0xc00c1917a0, 0xc0036f0c60, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/cache/load.go:123 +0x8b0
golang.org/x/tools/internal/lsp/cache.(*snapshot).packageHandles(0xc0002c0ea0, 0x1a5baa0, 0xc00c1917a0, 0x17c5fa0, 0xc0036f0c20, 0x0, 0x0, 0x0, 0xc0066bef20, 0x0, ...)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/cache/snapshot.go:135 +0x3b9
golang.org/x/tools/internal/lsp/cache.(*snapshot).PackageHandles(0xc0002c0ea0, 0x1a5baa0, 0xc00c191680, 0x1a59a20, 0xc004f8d420, 0x129233d, 0x1850480, 0xc004f8df80, 0xc0018d2990, 0xbf86c5aa4996d198)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/cache/snapshot.go:85 +0x306
golang.org/x/tools/internal/lsp/source.getParsedFile(0x1a5baa0, 0xc00c191680, 0x1a6bd00, 0xc0002c0ea0, 0x1a59a20, 0xc004f8d420, 0x1959438, 0x1a5baa0, 0xc00c191680, 0xc004f8df80, ...)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/source/util.go:71 +0x7d
golang.org/x/tools/internal/lsp/source.AllImportsFixes(0x1a5baa0, 0xc00c191680, 0x1a6bd00, 0xc0002c0ea0, 0x1a59a20, 0xc004f8d420, 0x0, 0xc0000bf5b0, 0x1, 0x1, ...)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/source/format.go:83 +0x183
golang.org/x/tools/internal/lsp.(*Server).codeAction(0xc00016fc00, 0x1a5baa0, 0xc0110e4540, 0xc007336280, 0xc007336280, 0x0, 0x0, 0x0, 0xc00844a420)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/code_action.go:74 +0x95a
golang.org/x/tools/internal/lsp.(*Server).CodeAction(0xc00016fc00, 0x1a5baa0, 0xc0110e4540, 0xc007336280, 0xc007336280, 0x0, 0x0, 0xc0034ff4e0, 0xbec94acc)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/server_gen.go:12 +0x4d
golang.org/x/tools/internal/lsp/protocol.serverHandler.Deliver(0x1a79dc0, 0xc00016fc00, 0x1a5baa0, 0xc0110e4540, 0xc0120fa500, 0xc0110e4500, 0xc011373090)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/protocol/tsserver.go:433 +0x25ff
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc00329db60, 0xc0120fa500, 0xc0002c8ea0, 0x1a5baa0, 0xc0110e4540, 0x0, 0x0, 0xc002b434b0)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:370 +0x170
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:354 

example 2

2020/02/05 14:25:05 : updateOverlay: modifying unopened overlay file:///Users/ilanpillemer/Repos/bxbdigital/bx-fs/filesystem/filesystem.go
[Trace - 14:25:05.144 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2020/02/05 14:25:05 : updateOverlay: modifying unopened overlay file:///Users/ilanpillemer/Repos/bxbdigital/bx-fs/filesystem/filesystem.go"}


[Trace - 14:25:05.448 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/02/05 14:25:05 go/packages.Load\n\tsnapshot = 0\n\tquery = [./... builtin]\n\tpackages = 4"}


[Error - 14:25:05.671 PM] Received #2 method "textDocument/definition" did not reply


panic: unexpected parse mode for command-line-arguments

goroutine 74 [running]:
golang.org/x/tools/internal/lsp/cache.expectMode(...)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/cache/snapshot.go:376
golang.org/x/tools/internal/lsp/cache.(*snapshot).packageHandle(0xc0000cc6c0, 0x1a5baa0, 0xc00642d950, 0xc008ee1460, 0x16, 0xc0087d0800, 0xc0009e1d80, 0xc0071eb378)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/cache/snapshot.go:113 +0x59d
golang.org/x/tools/internal/lsp/cache.(*snapshot).load(0xc0000cc6c0, 0x1a5baa0, 0xc00705f5f0, 0xc003317080, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/cache/load.go:123 +0x8b0
golang.org/x/tools/internal/lsp/cache.(*snapshot).packageHandles(0xc0000cc6c0, 0x1a5baa0, 0xc00705f5f0, 0x17c5fa0, 0xc003317070, 0x0, 0x0, 0x0, 0x5595bb8, 0x24, ...)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/cache/snapshot.go:135 +0x3b9
golang.org/x/tools/internal/lsp/cache.(*snapshot).PackageHandles(0xc0000cc6c0, 0x1a5baa0, 0xc0058f7bc0, 0x1a59a20, 0xc0059d4880, 0x129233d, 0x1850480, 0xc006e2c480, 0xc0059e82d0, 0xbf86d1f04976b6d8)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/cache/snapshot.go:85 +0x306
golang.org/x/tools/internal/lsp/source.getParsedFile(0x1a5baa0, 0xc0058f7bc0, 0x1a6bd00, 0xc0000cc6c0, 0x1a59a20, 0xc0059d4880, 0x1959438, 0x1a5baa0, 0xc0058f7bc0, 0xc006e2c480, ...)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/source/util.go:71 +0x7d
golang.org/x/tools/internal/lsp/source.Identifier(0x1a5baa0, 0xc0058f7bc0, 0x1a6bd00, 0xc0000cc6c0, 0x1a59a20, 0xc0059d4880, 0x4061e00000000000, 0x4040800000000000, 0x0, 0x0, ...)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/source/identifier.go:55 +0x133
golang.org/x/tools/internal/lsp.(*Server).definition(0xc0001bf650, 0x1a5baa0, 0xc000984db0, 0xc0059e40c0, 0xc0059e40c0, 0x0, 0x0, 0x0, 0xc00594e2c0)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/definition.go:29 +0x1c6
golang.org/x/tools/internal/lsp.(*Server).Definition(0xc0001bf650, 0x1a5baa0, 0xc000984db0, 0xc0059e40c0, 0xc0059e40c0, 0x0, 0x0, 0xc000666520, 0x2c1855ff)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/server_gen.go:32 +0x4d
golang.org/x/tools/internal/lsp/protocol.serverHandler.Deliver(0x1a79dc0, 0xc0001bf650, 0x1a5baa0, 0xc000984db0, 0xc00045cbc0, 0xc000984d00, 0xc0000e5b80)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/lsp/protocol/tsserver.go:389 +0x30b1
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc0001c60c0, 0xc00045cbc0, 0xc00029d140, 0x1a5baa0, 0xc000984db0, 0x0, 0x0, 0xc000a279e0)
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:370 +0x170
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
	/Users/ilanpillemer/go/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:354 +0x877

Build info

golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@(devel)
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
    golang.org/x/mod@v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/tools@v0.0.0-20191017151554-a3bc800455d5 => ../
    golang.org/x/xerrors@v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
    honnef.co/go/tools@v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info

go version go1.13.7 darwin/amd64

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ilanpillemer/Library/Caches/go-build"
GOENV="/Users/ilanpillemer/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY="bitbucket.org/bxbdigital"
GONOSUMDB="bitbucket.org/bxbdigital"
GOOS="darwin"
GOPATH="/Users/ilanpillemer/go"
GOPRIVATE="bitbucket.org/bxbdigital"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.7/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/z4/rs3f6lcs10l9rhf6wg4vdjt80000gn/T/go-build495654955=/tmp/go-build -gno-record-gcc-switches -fno-common"
@gopherbot gopherbot added this to the Unreleased milestone Feb 5, 2020
@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 Feb 5, 2020
@ilanpillemer ilanpillemer changed the title x/tools/gopls: goals panics on master when attempting to jump to a definition in a module not in a loaded workspace x/tools/gopls: gopls panics on master when attempting to jump to a definition in a module not in a loaded workspace Feb 5, 2020
@stamblerre stamblerre changed the title x/tools/gopls: gopls panics on master when attempting to jump to a definition in a module not in a loaded workspace x/tools/gopls: panics on master when attempting to jump to a definition in a module not in a loaded workspace Feb 5, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.0 Feb 5, 2020
@zikaeroh
Copy link
Contributor

zikaeroh commented Feb 5, 2020

I'm getting this as well. Notably, if you then restart gopls (which I do when I hit a weird case to try and fix it) while the out-of-workspace file is open, then gopls crashes at startup. Rolling back to before CL 217139 fixes it for me. I can get logs if needed.

@golang golang deleted a comment from gopherbot Feb 5, 2020
@gopherbot
Copy link

Change https://golang.org/cl/218322 mentions this issue: internal/lsp/lsprpc: add test for definition outside of workspace

@stamblerre stamblerre added the NeedsFix The path to resolution is known, but the work has not been done. label Feb 6, 2020
@stamblerre
Copy link
Contributor

Thanks for reporting this! This is caused by the fact that we only set the parse mode to "full" for packages in the workspace (forgetting to account for opened files). I will have a fix for this shortly.

@gopherbot
Copy link

Change https://golang.org/cl/218499 mentions this issue: internal/lsp/cache: fix panic when opening a non-workspace file

gopherbot pushed a commit to golang/tools that referenced this issue Feb 10, 2020
Add regression tests for GoToDefinition. In particular, exercise the
panic from golang/go#37045.

Updates golang/go#37045
Updates golang/go#36879

Change-Id: I67b562acd293f47907de0435c14b62c1a22cf2ee
Reviewed-on: https://go-review.googlesource.com/c/tools/+/218322
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@golang golang locked and limited conversation to collaborators Feb 6, 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. NeedsFix The path to resolution is known, but the work has not been done. 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