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 - index out of range #35468

Closed
bmhatfield opened this issue Nov 8, 2019 · 3 comments
Closed

x/tools/gopls: crash - index out of range #35468

bmhatfield opened this issue Nov 8, 2019 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@bmhatfield
Copy link

I believe this crash is highly related to #35455. In my local testing, I had demonstrated the new version did not crash, but after updating to master and installing, I am still experiencing an index out of range crash in the same rough area.

I triple checked that I was in fact running the new, fixed version, including by opening /Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/cache/session.go and confirming that the fix was in fact in the code path.

I'm not sure why this did not experimentally reproduce for me during the discussion with @matloob on #35455 , but it is consistently reproducing again now from master.

Included is the gopls output:

Go info
-------
go version go1.13.4 darwin/amd64

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/bhatfield/Library/Caches/go-build"
GOENV="/Users/bhatfield/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/bhatfield/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.4/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/w_/sj20ml6511v9vvzd4lzxhvlc0000gn/T/go-build756646728=/tmp/go-build -gno-record-gcc-switches -fno-common"

2019/11/08 15:17:49 : no metadata for file:///Users/bhatfield/Documents/digits/schema
panic: runtime error: index out of range [0] with length 0

goroutine 23 [running]:
golang.org/x/tools/internal/lsp/cache.(*session).bestView(0xc000196420, 0xc0002a8100, 0x78, 0x0, 0x0)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/cache/session.go:218 +0x18f
golang.org/x/tools/internal/lsp/cache.(*session).DidOpen(0xc000196420, 0x1833900, 0xc0001df1d0, 0xc0002a8100, 0x78, 0x0, 0xc000379000, 0xeb6, 0x1000, 0x1601fe0, ...)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/cache/session.go:255 +0x2b8
golang.org/x/tools/internal/lsp.(*Server).didOpen(0xc00013db60, 0x1833900, 0xc0001df1d0, 0xc000213000, 0x0, 0xc000240420)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/text_synchronization.go:29 +0x15e
golang.org/x/tools/internal/lsp.(*Server).DidOpen(0xc00013db60, 0x1833900, 0xc0001df1d0, 0xc000213000, 0xc000213000, 0x0)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/server.go:135 +0x49
golang.org/x/tools/internal/lsp/protocol.serverHandler.Deliver(0x1848600, 0xc00013db60, 0x1833900, 0xc0001df1d0, 0xc0002a2000, 0xc0001df100, 0xc0001981e0)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/protocol/tsserver.go:111 +0x1b66
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc0001a0360, 0xc0002a2000, 0xc00013dbc0, 0x1833900, 0xc0001df1d0, 0x0, 0x0, 0xc00016cce0)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/jsonrpc2/jsonrpc2.go:370 +0x170
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
	/Users/bhatfield/go/src/github.com/golang/tools/internal/jsonrpc2/jsonrpc2.go:354 +0x877
[Error - 3:17:49 PM] 2019/11/08 15:17:49 : no metadata for file:///Users/bhatfield/Documents/digits/schema
[Error - 3:17:49 PM] Connection to server got closed. Server will not be restarted.

@matloob I can confirm just like in #35455 that the "schema" referenced here does not have go modules in it.

@gopherbot gopherbot added this to the Unreleased milestone Nov 8, 2019
@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 Nov 8, 2019
@gopherbot
Copy link

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.

@muirdm
Copy link

muirdm commented Nov 9, 2019

I'm seeing this too when creating an overlay file in an empty directory (i.e. no go.mod).

@gopherbot
Copy link

Change https://golang.org/cl/206497 mentions this issue: internal/lsp/cache: have NewView create view even if load all packages fails

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. 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