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: panic in completion on variables of type *error #56505

Closed
Sophie1142 opened this issue Oct 31, 2022 · 4 comments
Closed

x/tools/gopls: panic in completion on variables of type *error #56505

Sophie1142 opened this issue Oct 31, 2022 · 4 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

@Sophie1142
Copy link

gopls version: v0.10.0 (go1.19)
gopls flags:
update flags: proxy
extension version: 0.35.2
go version: 1.19
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Mon, 31 Oct 2022 23:27:13 GMT
restart history:
Mon, 31 Oct 2022 21:26:18 GMT: activation (enabled: true)
Mon, 31 Oct 2022 21:36:32 GMT: installation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

I got a pop-up notification from VSCode Gopls crashed, and then another one saying "Connection to server got closed. Server will not be restarted." This has not happened before in my ~2 months working with Go.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104f57374]

goroutine 138 [running]:
go/types.(*Package).Path(...)
	  package.go:31
golang.org/x/tools/gopls/internal/lsp/source/completion.isStarTestingDotF({0x10541e298%3F, 0x14009707640%3F})
	  completion.go:1283  0x74
golang.org/x/tools/gopls/internal/lsp/source/completion.(*completer).methodsAndFields(0x1400046e000, {0x10541e298%3F, 0x14009707640}, 0x1, 0x0, 0x14004a4ced0)
	  completion.go:1246  0x198
golang.org/x/tools/gopls/internal/lsp/source/completion.(*completer).deepSearch(0x1400046e000, {0x105422288%3F, 0x14002416f60%3F})
	  deep_completion.go:229  0x88c
golang.org/x/tools/gopls/internal/lsp/source/completion.Completion({0x105422218%3F, 0x1400030a780%3F}, {0x10542ddc0%3F, 0x140063dedc0}, {0x105422528%3F, 0x14000351960}, {0xeaf200%3F, 0x140%3F}, {0x2e1da40%3F, {0x0%3F, ...}})
	  completion.go:571  0xd6c
golang.org/x/tools/gopls/internal/lsp.(*Server).completion(0x14002cf69b0%3F, {0x105422218, 0x1400030a780}, 0x14002cf69b0)
	  completion.go:32  0x134
golang.org/x/tools/gopls/internal/lsp.(*Server).Completion(0x140002ae300%3F, {0x105422218%3F, 0x1400030a780%3F}, 0x1052b0e80%3F)
	  server_gen.go:28  0x24
golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch({0x105422218, 0x1400030a780}, {0x1054311c0, 0x140001e0000}, 0x14002e1d620, {0x105422608, 0x1400030a700})
	  tsserver.go:269  0x1a24
golang.org/x/tools/gopls/internal/lsp/protocol.ServerHandler.func1({0x105422218, 0x1400030a780}, 0x14002e1d620, {0x105422608, 0x1400030a700})
	  protocol.go:157  0x6c
golang.org/x/tools/gopls/internal/lsp/lsprpc.handshaker.func1({0x105422218, 0x1400030a780}, 0x14002e1d620, {0x105422608%3F, 0x1400030a700%3F})
	  lsprpc.go:515  0x77c
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1({0x105422218, 0x1400030a780}, 0x140002e9440, {0x105422608%3F, 0x1400030a700%3F})
	  handler.go:35  0xf0
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2()
	  handler.go:103  0x90
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	  handler.go:100  0x1dc
[Error - 4:27:01 PM] 

OPTIONAL: If you would like to share more information, you can attach your complete gopls logs.

NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE.
DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.

<OPTIONAL: ATTACH LOGS HERE>

@findleyr findleyr changed the title gopls: automated issue report (crash) x/tools/gopls: panic in completion on variables of type *error Nov 1, 2022
@findleyr
Copy link
Contributor

findleyr commented Nov 1, 2022

Thank you for the report. This was straightforward to track down based on the panicking stack: I believe this is only possible during completion on variables of type *error.

@findleyr findleyr transferred this issue from golang/vscode-go Nov 1, 2022
@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 1, 2022
@gopherbot gopherbot added this to the Unreleased milestone Nov 1, 2022
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.10.1 Nov 1, 2022
@gopherbot
Copy link

Change https://go.dev/cl/446815 mentions this issue: gopls/internal/lsp/source/completion: fix panic in completion on *error

@gopherbot
Copy link

Change https://go.dev/cl/446861 mentions this issue: [gopls-release-branch.0.10] gopls/internal/lsp/source/completion: fix panic in completion on *error

gopherbot pushed a commit to golang/tools that referenced this issue Nov 1, 2022
… panic in completion on *error

Fix a panic during completion on variables of type *error. As a
predeclared type, the error type has nil package. Fix the crash
resulting from this oversight, as well as a related crash in the tests
analyzer, from which the new completion code was adapted.

Fixes golang/go#56505

Change-Id: I0707924d0666b238821fd14b6fc34639cc7a9c53
Reviewed-on: https://go-review.googlesource.com/c/tools/+/446815
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
(cherry picked from commit 6e9dc86)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/446861
@findleyr
Copy link
Contributor

findleyr commented Nov 1, 2022

This fix has been released in gopls@v0.10.1

@golang golang locked and limited conversation to collaborators Nov 1, 2023
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

3 participants