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/internal/lsp/cache: nil pointer dereference in snapshot.getPackageHandles (v0.12.4) #61420

Closed
invisibleDesigner opened this issue Jul 18, 2023 · 3 comments
Labels
gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@invisibleDesigner
Copy link

gopls version: v0.12.4 (go1.20.6)
gopls flags:
update flags: proxy
extension version: 0.39.0
go version: 1.20.6
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Tue, 18 Jul 2023 02:24:16 GMT
restart history:
Mon, 17 Jul 2023 07:44:16 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

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

goroutine 3755 [running]:
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func1({0xc000923f80, 0x23})
	  check.go:787  0x178
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func1({0xc0002ae900, 0x8a})
	  check.go:788  0x1d7
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles(0xc003fd0000, {0x100d63978, 0xc0002608d0}, {0xc000710500, 0x1, 0x0%3F})
	  check.go:792  0x246
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackage(0x100d63978%3F, {0x100d63978, 0xc0002605a0}, {0xc000710500, 0x1, 0x1}, 0xc000710500%3F, 0x0%3F)
	  check.go:341  0x1d9
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).PackageDiagnostics(0xc00007af68%3F, {0x100d63978%3F, 0xc0006c2d20%3F}, {0xc000710500, 0x1, 0x1})
	  snapshot.go:666  0x1fc
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnosePkgs.func1()
	  diagnostics.go:441  0x1dc
created by golang.org/x/tools/gopls/internal/lsp.(*Server).diagnosePkgs
	  diagnostics.go:434  0x205
[Error - 10:23:59] 

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>

@hyangah hyangah transferred this issue from golang/vscode-go Jul 18, 2023
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jul 18, 2023
@hyangah hyangah changed the title gopls: automated issue report (crash) x/tools/gopls/internal/lsp/cache: nil pointer dereference in snapshot.getPackageHandles (v0.12.4) Jul 18, 2023
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jul 18, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jul 18, 2023
@gopherbot
Copy link

Change https://go.dev/cl/510701 mentions this issue: gopls/internal/lsp/cache: better panic if metadata invariant is broken

gopherbot pushed a commit to golang/tools that referenced this issue Jul 18, 2023
As an invariant, we should always have metadata available for all packages in
DepsByPackagePath. Add a more useful panic for golang/go#61420.

For golang/go#61420

Change-Id: Ia4aa847163e54e6d3ba3d20b8ce14938d36087c5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/510701
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
@jamalc jamalc modified the milestones: Unreleased, gopls/v0.12.5 Jul 20, 2023
@adonovan adonovan added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 25, 2023
@findleyr
Copy link
Contributor

@invisibleDesigner have you hit this again since your original report? I'd love to track it down.

In "61543", this was caused by a module named "command-line-arguments". Do you have such a module?

You may also want to try the latest gopls prerelease, which has restructured this code a bit and may give a more useful panic when it encounters this unexpected condition.

go install golang.org/x/tools/gopls@v0.13.0-pre.2

@findleyr
Copy link
Contributor

Absent more information, I don't think this is actionable. Let's fix 61543 and hope that was the root cause.

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants