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 a method has a parameter of type comparable #60544

Closed
thatguystone opened this issue Jun 1, 2023 · 3 comments
Closed
Assignees
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

@thatguystone
Copy link

To reproduce:

$ go mod init github.com/thatguystone/crash
go: creating new go.mod: module github.com/thatguystone/crash
$ code .
$ echo "package main

type X struct{}

func (X) test(x comparable) {}
" > main.go
$ code main.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xa31edd]

goroutine 162 [running]:
golang.org/x/tools/gopls/internal/lsp/source.NarrowestPackageForFile({0x1176b98, 0xc001456870}, {0x1183ed0, 0xc003232180}, {0xc00205e540, 0x27})
	  view.go:303  0x2dd
golang.org/x/tools/gopls/internal/lsp.(*Server).codeAction(0xd74d60%3F, {0x1176af0%3F, 0xc000374a00%3F}, 0xc00089fea0)
	  code_action.go:198  0x1738
golang.org/x/tools/gopls/internal/lsp.(*Server).CodeAction(0xc0002bc300%3F, {0x1176af0%3F, 0xc000374a00%3F}, 0xd74d60%3F)
	  server_gen.go:16  0x25
golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch({0x1176af0, 0xc000374a00}, {0x1187810, 0xc000771c70}, 0xc001456630, {0x1176dc8, 0xc0000c86c0})
	  tsserver.go:237  0x1f05
golang.org/x/tools/gopls/internal/lsp/protocol.ServerHandler.func1({0x1176af0, 0xc000374a00}, 0xc001456630, {0x1176dc8, 0xc0000c86c0})
	  protocol.go:157  0x90
golang.org/x/tools/gopls/internal/lsp/lsprpc.handshaker.func1({0x1176af0, 0xc000374a00}, 0xc001456630, {0x1176dc8%3F, 0xc0000c86c0%3F})
	  lsprpc.go:519  0x9f9
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1({0x1176af0, 0xc000374a00}, 0xc0003cec60, {0x1176dc8%3F, 0xc0000c86c0%3F})
	  handler.go:35  0xf6
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2()
	  handler.go:103  0xa3
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	  handler.go:100  0x20a
[Error - 5:28:11 PM] 
@findleyr
Copy link
Contributor

findleyr commented Jun 1, 2023

Thank you for the report, and especially for narrowing down the repro.

Reproduces with v0.12.0, but not v0.11.0, so this is a regression. Transferring to the gopls issue tracker.

@findleyr findleyr changed the title gopls: automated issue report (crash): crashes when a method has a parameter of type comparable x/tools/gopls: crash when a method has a parameter of type comparable Jun 1, 2023
@findleyr findleyr transferred this issue from golang/vscode-go Jun 1, 2023
@findleyr findleyr self-assigned this Jun 1, 2023
@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 Jun 1, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jun 1, 2023
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.12.1 Jun 1, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/499196 mentions this issue: gopls/internal/lsp/source/methodsets: comparable also has no package

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/499986 mentions this issue: gopls/internal/lsp/source: fix panic in typeDefinition on comparable

gopherbot pushed a commit to golang/tools that referenced this issue Jun 1, 2023
comparable is also permitted to have no position.

Updates golang/go#60544

Change-Id: Ic0694796432ab8b3271a60e4f4f649a1657d462b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/499986
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
@golang golang locked and limited conversation to collaborators May 31, 2024
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