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 when resolving git conflicts in vscode #36162

Closed
bmhatfield opened this issue Dec 16, 2019 · 5 comments
Closed

x/tools/gopls: crash when resolving git conflicts in vscode #36162

bmhatfield opened this issue Dec 16, 2019 · 5 comments
Assignees
Labels
Milestone

Comments

@bmhatfield
Copy link

@bmhatfield bmhatfield commented Dec 16, 2019

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

go 1.13.4 (latest available in Homebrew)

Does this issue reproduce with the latest release?

Currently using gopls from HEAD: 49a3e744

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

OSX

What did you do?

Editing source code with merge conflict headers in them (in VSCode)

What did you expect to see?

Standard VSCode interface to resolving merge conflicts, until they were done

What did you see instead?

The gopls server crashed 5 times in the last 3 minutes. The server will not be restarted.

[Info  - 9:35:30 AM] 2019/12/16 09:35:30 go/packages.Load
	package = command-line-arguments
	files = [/Users/bhatfield/Documents/digits/go-services/services/internal-apis/comment/models/comment/comment.go]
[Error - 9:35:30 AM] Request textDocument/codeAction failed.
  Message: method "textDocument/codeAction" did not reply
  Code: -32603 
panic: runtime error: slice bounds out of range [17:0]

goroutine 11 [running]:
golang.org/x/tools/internal/lsp/source.trimToImports(0xc000070fc0, 0xc00d50f800, 0xc010501c00, 0x61e, 0x700, 0x185a0e0, 0xc010d0df00, 0x0, 0x0)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/source/format.go:273 +0x505
golang.org/x/tools/internal/lsp/source.computeImportEdits(0x1867880, 0xc01237d740, 0x1875860, 0xc0002d0000, 0x1867b00, 0xc010d0da40, 0xc010d25ca0, 0xc010cbe500, 0x2, 0x2, ...)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/source/format.go:135 +0x239
golang.org/x/tools/internal/lsp/source.AllImportsFixes.func1(0xc010d25ca0, 0x1867800, 0xc01237d740)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/source/format.go:111 +0xe8
golang.org/x/tools/internal/lsp/cache.(*view).RunProcessEnvFunc(0xc0002d0000, 0x1867880, 0xc01237d740, 0xc008ff73b0, 0xc010d25ca0, 0x0, 0x0)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/cache/view.go:175 +0xf6
golang.org/x/tools/internal/lsp/source.AllImportsFixes(0x1867880, 0xc01237d740, 0x1871620, 0xc000200780, 0x35c0060, 0xc00c9f8400, 0x0, 0x2, 0x0, 0x100, ...)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/source/format.go:110 +0x698
golang.org/x/tools/internal/lsp.(*Server).codeAction(0xc0002160e0, 0x1867880, 0xc0002268a0, 0xc011671b80, 0xc011671b80, 0x0, 0x0, 0x0, 0xc019491c30)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/code_action.go:74 +0x81c
golang.org/x/tools/internal/lsp.(*Server).CodeAction(0xc0002160e0, 0x1867880, 0xc0002268a0, 0xc011671b80, 0xc011671b80, 0x0, 0x0, 0x0, 0x0)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/server.go:217 +0x4d
golang.org/x/tools/internal/lsp/protocol.serverHandler.Deliver(0x187d3c0, 0xc0002160e0, 0x1867880, 0xc0002268a0, 0xc000071680, 0xc000226800, 0xc000200410)
	/Users/bhatfield/go/src/github.com/golang/tools/internal/lsp/protocol/tsserver.go:403 +0x240d
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc00002e480, 0xc000071680, 0xc0001f6ba0, 0x1867880, 0xc0002268a0, 0x0, 0x0, 0xc00005a810)
	/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 - 9:35:30 AM] Connection to server got closed. Server will not be restarted.
[Error - 9:35:30 AM] Request textDocument/documentLink failed.
@gopherbot gopherbot added this to the Unreleased milestone Dec 16, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Dec 16, 2019

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.

@bmhatfield

This comment has been minimized.

Copy link
Author

@bmhatfield bmhatfield commented Dec 16, 2019

Note: after reviewing the source code referenced in the backtrace (here), I can confirm that a merge conflict did exist within the import block.

@muirdm

This comment has been minimized.

Copy link

@muirdm muirdm commented Dec 16, 2019

/cc @heschik

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Dec 16, 2019

Reproduces easily enough:

package imports //@import("package")

import (
	"bytes"
<<< HERE'S SOME NONSENSE FOR YOU
	"fmt"
=== WHEE
>>> MORE NONSENSE
)

func _() {
	fmt.Println("")
	bytes.
}

Can't write a test because our test framework can't cope with a file this broken, but the fix is easy.

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Dec 16, 2019

Change https://golang.org/cl/211580 mentions this issue: internal/lsp/source: fix crash on conflict markers in imports

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
5 participants
You can’t perform that action at this time.