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/cmd/gopls: panic "illegal file offset" #32639

Closed
CannibalVox opened this issue Jun 16, 2019 · 3 comments
Closed

x/tools/cmd/gopls: panic "illegal file offset" #32639

CannibalVox opened this issue Jun 16, 2019 · 3 comments

Comments

@CannibalVox
Copy link

@CannibalVox CannibalVox commented Jun 16, 2019

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

$ go version
go version go1.12.6 windows/amd64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Stephen Baynham\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Stephen Baynham\go
set GOPROXY=
set GORACE=
set GOROOT=c:\go
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\STEPHE~1\AppData\Local\Temp\go-build699515794=/tmp/go-build -gno-record-gcc-switches

What did you do?

I opened VSCode with the Go extension and gopls activated. I moused over the red underline error in the following code:

package luatypes

import (
	lua "github.com/yuin/gopher-lua"
	luar "layeh.com/gopher-luar"
)

func InitTypes(L *lua.LState) {
	locType := luar.NewType(L, Loc{})
	userData, ok := locType.(*lua.)
}

What did you expect to see?

Receive error information, autocomplete, etc.

What did you see instead?

Gopls instantly crashed 5 times, causing VSCode to permanently retire it for the rest of my session:

[Info  - 1:22:09 AM] Build info
----------
version v0.1.0-cmd.gopls, built in $GOPATH mode

Go info
-------
go version go1.12.6 windows/amd64

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Stephen Baynham\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Stephen Baynham\go
set GOPROXY=
set GORACE=
set GOROOT=c:\go
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=c:\Users\Stephen Baynham\Desktop\altserver\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\STEPHE~1\AppData\Local\Temp\go-build272807422=/tmp/go-build -gno-record-gcc-switches

panic: illegal file offset

goroutine 6 [running]:
go/token.(*File).Pos(...)
	c:/go/src/go/token/position.go:267
golang.org/x/tools/internal/span.Span.Range(0xc0003e8af0, 0x43, 0xa, 0x1f, 0xbf, 0xa, 0x1f, 0xbf, 0xc0011e4370, 0x0, ...)
	C:/Users/Stephen Baynham/go/src/golang.org/x/tools/internal/span/token.go:104 +0x373
golang.org/x/tools/internal/lsp.organizeImports(0xb5d5e0, 0xc0018fcb70, 0xb66720, 0xc000196b60, 0xc0003e8af0, 0x43, 0xa, 0x1f, 0xbf, 0xa, ...)
	C:/Users/Stephen Baynham/go/src/golang.org/x/tools/internal/lsp/code_action.go:70 +0x141
golang.org/x/tools/internal/lsp.(*Server).codeAction(0xc000190a00, 0xb5d5e0, 0xc0018fcb70, 0xc0017eb2c0, 0xc0017eb2c0, 0x0, 0x0, 0x0, 0xc0021c83c0)
	C:/Users/Stephen Baynham/go/src/golang.org/x/tools/internal/lsp/code_action.go:32 +0x1f8
golang.org/x/tools/internal/lsp.(*Server).CodeAction(0xc000190a00, 0xb5d5e0, 0xc0018fcb70, 0xc0017eb2c0, 0xc0017eb2c0, 0x0, 0x0, 0x0, 0x0)
	C:/Users/Stephen Baynham/go/src/golang.org/x/tools/internal/lsp/server.go:203 +0x54
golang.org/x/tools/internal/lsp/protocol.serverHandler.func1(0xb5d5e0, 0xc0018fcb70, 0xc0001f4000, 0xc000384020)
	C:/Users/Stephen Baynham/go/src/golang.org/x/tools/internal/lsp/protocol/tsserver.go:355 +0x2e7e
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc00004b2c0, 0xc0001f4000)
	C:/Users/Stephen Baynham/go/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:288 +0x190
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
	C:/Users/Stephen Baynham/go/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:278 +0xc1
[Info  - 1:22:10 AM] Connection to server got closed. Server will restart.
[Error - 1:22:10 AM] Request textDocument/codeAction failed.
Error: Connection got disposed.
	at Object.dispose (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\main.js:876:25)
	at Object.dispose (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\client.js:57:35)
	at LanguageClient.handleConnectionClosed (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\client.js:2036:42)
	at LanguageClient.handleConnectionClosed (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\main.js:127:15)
	at closeHandler (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\client.js:2023:18)
	at CallbackList.invoke (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:120:36)
	at closeHandler (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\main.js:226:26)
	at CallbackList.invoke (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:120:36)
	at StreamMessageReader.fireClose (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\messageReader.js:111:27)
	at Socket.listen.readable.on (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\messageReader.js:151:46)
	at Socket.emit (events.js:187:15)
	at Pipe.Socket._destroy._handle.close [as _onclose] (net.js:596:12)
[Error - 1:22:10 AM] Request textDocument/documentLink failed.
Error: Connection got disposed.
	at Object.dispose (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\main.js:876:25)
	at Object.dispose (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\client.js:57:35)
	at LanguageClient.handleConnectionClosed (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\client.js:2036:42)
	at LanguageClient.handleConnectionClosed (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\main.js:127:15)
	at closeHandler (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\client.js:2023:18)
	at CallbackList.invoke (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:120:36)
	at closeHandler (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\main.js:226:26)
	at CallbackList.invoke (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:120:36)
	at StreamMessageReader.fireClose (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\messageReader.js:111:27)
	at Socket.listen.readable.on (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\messageReader.js:151:46)
	at Socket.emit (events.js:187:15)
	at Pipe.Socket._destroy._handle.close [as _onclose] (net.js:596:12)
[Error - 1:22:10 AM] Request textDocument/codeAction failed.
Error: Connection got disposed.
	at Object.dispose (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\main.js:876:25)
	at Object.dispose (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\client.js:57:35)
	at LanguageClient.handleConnectionClosed (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\client.js:2036:42)
	at LanguageClient.handleConnectionClosed (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\main.js:127:15)
	at closeHandler (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-languageclient\lib\client.js:2023:18)
	at CallbackList.invoke (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:120:36)
	at closeHandler (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\main.js:226:26)
	at CallbackList.invoke (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\events.js:120:36)
	at StreamMessageReader.fireClose (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\messageReader.js:111:27)
	at Socket.listen.readable.on (C:\Users\Stephen Baynham\.vscode\extensions\ms-vscode.go-0.10.2\node_modules\vscode-jsonrpc\lib\messageReader.js:151:46)
	at Socket.emit (events.js:187:15)
	at Pipe.Socket._destroy._handle.close [as _onclose] (net.js:596:12)
[Info  - 1:22:10 AM] Build info
----------
version v0.1.0-cmd.gopls, built in $GOPATH mode

Go info
-------
go version go1.12.6 windows/amd64
...
etc.
@gopherbot gopherbot added this to the Unreleased milestone Jun 16, 2019
@gopherbot gopherbot added the gopls label Jun 16, 2019
@CannibalVox
Copy link
Author

@CannibalVox CannibalVox commented Jun 16, 2019

On further tinkering, I discovered that the file was not saved- vscode was keeping it between sessions. After saving it, mousing over does not reproduce the issue, but if I spacebar -> ctrl+s at the bottom of the file, it will crash gopls exactly once.

@stamblerre stamblerre changed the title x/tools/cmd/gopls: Panic "illegal file offset" x/tools/cmd/gopls: panic "illegal file offset" Jun 17, 2019
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 17, 2019

Are you able to share the log from a run of gopls from when the file is saved and it crashes?

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 27, 2019

Change https://golang.org/cl/184038 mentions this issue: internal/span: catch potential panics in go/token

gopherbot pushed a commit to golang/tools that referenced this issue Jun 27, 2019
Updates golang/go#32639

Change-Id: Ib413fc316af4308d8928647ff36a437d243a9c11
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184038
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
@stamblerre stamblerre closed this Jul 1, 2019
@golang golang locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.