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/internal/lsp: nil pointer panic in cache/pkg.go #32378

Closed
muirdm opened this issue Jun 1, 2019 · 2 comments
Closed

x/tools/internal/lsp: nil pointer panic in cache/pkg.go #32378

muirdm opened this issue Jun 1, 2019 · 2 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@muirdm
Copy link

muirdm commented Jun 1, 2019

It looks like this regressed in golang/tools@12d7342#diff-33a4b83a3d750539392acd0f451849ebR164. GetImport must guard against returning a nil *pkg pointer because that results in a not-nil but panicky source.Package.

/cc @stamblerre

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x1380355]

goroutine 8 [running]:
golang.org/x/tools/internal/lsp/cache.(*pkg).GetSyntax(0x0, 0xc0003f8b07, 0x3, 0x1755200)
	/Users/muir/projects/tools/internal/lsp/cache/pkg.go:141 +0x5
golang.org/x/tools/internal/lsp/source.importSpec(0x1753800, 0xc0002d8000, 0xc0004f8400, 0x1755200, 0xc00052c480, 0x1cbc5, 0x1, 0x0, 0x0)
	/Users/muir/projects/tools/internal/lsp/source/identifier.go:229 +0x20a
golang.org/x/tools/internal/lsp/source.identifier(0x174d600, 0xc0000309c0, 0x1755b80, 0xc000266000, 0x1753800, 0xc0002d8000, 0x1cbc5, 0x0, 0x0, 0x0)
	/Users/muir/projects/tools/internal/lsp/source/identifier.go:71 +0x2a3
golang.org/x/tools/internal/lsp/source.Identifier(0x174d600, 0xc0000309c0, 0x1755b80, 0xc000266000, 0x1753800, 0xc0002d8000, 0x1cbc6, 0x1a, 0xc0003c4300, 0xc0001ba4c0)
	/Users/muir/projects/tools/internal/lsp/source/identifier.go:47 +0x117
golang.org/x/tools/internal/lsp.(*Server).hover(0xc0001703f0, 0x174d600, 0xc0000309c0, 0xc00049ed00, 0x0, 0x0, 0xc000536a00)
	/Users/muir/projects/tools/internal/lsp/hover.go:31 +0x243
golang.org/x/tools/internal/lsp.(*Server).Hover(0xc0001703f0, 0x174d600, 0xc0000309c0, 0xc00049ed00, 0xc00049ed00, 0x0, 0x0)
	/Users/muir/projects/tools/internal/lsp/server.go:170 +0x49
golang.org/x/tools/internal/lsp/protocol.serverHandler.func1(0x174d600, 0xc0000309c0, 0xc000170460, 0xc00026ffa0)
	/Users/muir/projects/tools/internal/lsp/protocol/tsserver.go:285 +0x1657
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc000092d20, 0xc000170460)
	/Users/muir/projects/tools/internal/jsonrpc2/jsonrpc2.go:276 +0xda
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
	/Users/muir/projects/tools/internal/jsonrpc2/jsonrpc2.go:270 +0xba
@gopherbot gopherbot added this to the Unreleased milestone Jun 1, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jun 1, 2019
@stamblerre
Copy link
Contributor

@muirrn: Thanks for catching this, I thought that https://go-review.googlesource.com/c/tools/+/178724 would prevent this from happening, but I didn't actually handle this case.

@gopherbot
Copy link

Change https://golang.org/cl/179919 mentions this issue: internal/lsp: fix regression from CL 179439

@golang golang locked and limited conversation to collaborators Jun 2, 2020
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.
Projects
None yet
Development

No branches or pull requests

3 participants