Skip to content

x/tools/gopls: crash when a method has a parameter of type comparable #60544

Closed
@thatguystone

Description

@thatguystone

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] 

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions