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

tools/internal/lsp: panic in go/packages during package rename #35035

Closed
leitzler opened this issue Oct 21, 2019 · 2 comments
Closed

tools/internal/lsp: panic in go/packages during package rename #35035

leitzler opened this issue Oct 21, 2019 · 2 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.

Comments

@leitzler
Copy link
Contributor

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

$ go version
go1.13

Does this issue reproduce with the latest release?

N/A.
I'm running the tools master-branch, i.e. ed542cd

What did you do?

In a medium sized project I moved a file from one package to another before gopls was running, so that I had a package that contained several go files where one of them had an incorrect package ...-declaration at the top.

Then I opened the file in vim (govim) and renamed the package, effectively to another non-existing package name (since the change triggeded a didChange before I had completed my typing).

That resulted in a panic in gopls:

panic: assignment to entry in nil map

goroutine 7172 [running]:
golang.org/x/tools/go/packages.processGolistOverlay(0xc00630f088, 0xc00b78d5b0, 0xc00b78d5c8, 0xc01e0fb810, 0x1, 0x1, 0xc0006b75c8, 0x0, 0x0, 0xbb1e80, ...)
	/home/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a/go/packages/golist_overlay.go:142 +0xb0d
golang.org/x/tools/go/packages.goListDriver(0xc00630f088, 0xc01e0fb7c0, 0x1, 0x1, 0x8, 0x10, 0xc00630f080)
	/home/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a/go/packages/golist.go:208 +0x57a
golang.org/x/tools/go/packages.defaultDriver(0xc00630f088, 0xc01e0fb7c0, 0x1, 0x1, 0xc01ddd88f0, 0xc0001c4d80, 0x4b)
	/home/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a/go/packages/packages.go:225 +0x68
golang.org/x/tools/go/packages.Load(0xc01e25e080, 0xc01e0fb7c0, 0x1, 0x1, 0x1, 0xc01dd85720, 0x4b, 0xda0020, 0xc01e21a270)
	/home/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a/go/packages/packages.go:210 +0x6f
golang.org/x/tools/internal/lsp/cache.(*snapshot).load(0xc01d4eb810, 0xda0020, 0xc01e21a270, 0xc000176230, 0x4d, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a/internal/lsp/cache/load.go:41 +0x2f3
golang.org/x/tools/internal/lsp/cache.(*snapshot).checkPackageHandles(0xc01d4eb810, 0xda0020, 0xc01e21a1b0, 0x7f0d87bec278, 0xc00027d2c0, 0x1152f9e4b, 0x127a620, 0xc01e21a1b0, 0xc01e21a180, 0xbf638ad35e2a00bf)
	/home/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a/internal/lsp/cache/gofile.go:42 +0x4b8
golang.org/x/tools/internal/lsp/cache.(*view).CheckPackageHandles(0xc00008ed80, 0xda0020, 0xc01e21a1b0, 0x7f0d87bec278, 0xc00027d2c0, 0x1, 0x1, 0xda0020, 0xc01e21a1b0, 0xc01e153a00, ...)
	/home/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a/internal/lsp/cache/gofile.go:20 +0x76
golang.org/x/tools/internal/lsp/source.Diagnostics(0xda0020, 0xc01e21a1b0, 0xdb0640, 0xc00008ed80, 0x7f0d87bec278, 0xc00027d2c0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a/internal/lsp/source/diagnostics.go:44 +0x1e8
golang.org/x/tools/internal/lsp.(*Server).diagnostics(0xc00027ea20, 0xdb0640, 0xc00008ed80, 0xc01dd85540, 0x4d, 0x0, 0x0)
	/home/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a/internal/lsp/diagnostics.go:30 +0x2e0
created by golang.org/x/tools/internal/lsp.(*Server).didChange
	/home/leitzler/go/pkg/mod/golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a/internal/lsp/text_synchronization.go:82 +0x373
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Oct 21, 2019
@leitzler
Copy link
Contributor Author

@gopherbot please add label Tools

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Oct 21, 2019
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/202537 mentions this issue: go/packages: create Imports map when creating package

@golang golang locked and limited conversation to collaborators Oct 20, 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. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants