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: panic in Analyze with patch version in go.mod file #66636

Closed
irahardianto opened this issue Mar 30, 2024 · 5 comments
Closed

x/tools/gopls: panic in Analyze with patch version in go.mod file #66636

irahardianto opened this issue Mar 30, 2024 · 5 comments
Assignees
Labels
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

@irahardianto
Copy link

gopls version: v0.15.2/go1.20.4
gopls flags:
update flags: proxy
extension version: 0.41.2
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Sat, 30 Mar 2024 00:43:17 GMT
restart history:
Fri, 29 Mar 2024 22:57:47 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: invalid Go version "go1.22.1" (should be something like "go1.12")

goroutine 191 [running]:
go/types.NewChecker(0x140002ba5d0%3F, 0x140004b60c0, 0x140001e9310, 0x0%3F)
	  check.go:237  0x1e8
golang.org/x/tools/gopls/internal/cache.(*analysisNode).typeCheck(0x140003a8000, {0x14000292410, 0x1, 0x1})
	  analysis.go:1028  0x5fc
golang.org/x/tools/gopls/internal/cache.(*analysisNode).run(0x140003a8000, {0x101c1e998%3F, 0x14000497e30})
	  analysis.go:810  0x1d4
golang.org/x/tools/gopls/internal/cache.(*analysisNode).runCached(0x140003a8000, {0x101c1e998%3F, 0x14000497e30})
	  analysis.go:672  0x104
golang.org/x/tools/gopls/internal/cache.(*Snapshot).Analyze.func6.1()
	  analysis.go:398  0xa4
golang.org/x/sync/errgroup.(*Group).Go.func1()
	  errgroup.go:78  0x5c
created by golang.org/x/sync/errgroup.(*Group).Go
	  errgroup.go:75  0xa0
gopls stats -anon { "DirStats": { "Files": 29, "TestdataFiles": 0, "GoFiles": 1, "ModFiles": 1, "Dirs": 20 }, "GOARCH": "arm64", "GOOS": "darwin", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.20.4", "GoplsVersion": "v0.15.2", "InitialWorkspaceLoadDuration": "55.90625ms", "MemStats": { "HeapAlloc": 2758320, "HeapInUse": 5218304, "TotalAlloc": 12841176 }, "WorkspaceStats": { "Files": { "Total": 2, "Largest": 57, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.1", "AllPackages": { "Packages": 1, "LargestPackage": 1, "CompiledGoFiles": 1, "Modules": 1 }, "WorkspacePackages": { "Packages": 1, "LargestPackage": 1, "CompiledGoFiles": 1, "Modules": 1 }, "Diagnostics": 1 } ] } }

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>

@findleyr findleyr changed the title gopls: automated issue report (crash) x/tools/gopls: panic in Analyze with patch version in go.mod file Apr 1, 2024
@findleyr
Copy link
Member

findleyr commented Apr 1, 2024

This is exactly like #66195, but in Analyze rather than TypeCheck.

Transferring to the Go issue tracker, and fixing in gopls@v0.15.3.

@findleyr findleyr transferred this issue from golang/vscode-go Apr 1, 2024
@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 Apr 1, 2024
@gopherbot gopherbot added this to the Unreleased milestone Apr 1, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.15.3 Apr 1, 2024
@findleyr findleyr self-assigned this Apr 1, 2024
@findleyr
Copy link
Member

findleyr commented Apr 1, 2024

For now, a viable workaround is to install gopls with go1.21+.

However, since this version of gopls nominally supports being built with 1.20, we should fix the crash.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/576135 mentions this issue: gopls/internal/cache: fix crash in snapshot.Analyze with patch versions

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/577301 mentions this issue: [gopls-release-branch.0.15] gopls/internal/cache: fix crash in snapshot.Analyze with patch versions

gopherbot pushed a commit to golang/tools that referenced this issue Apr 8, 2024
…ot.Analyze with patch versions

Fix the same crash as golang/go#66195, this time in Analyze: don't set
invalid Go versions on the types.Config.

The largest part of this change was writing a realistic test, since the
lack of a test for golang/go#66195 caused us to miss this additional
location. It was possible to create a test that worked, by using a flag
to select a go1.21 binary location.

For this test, it was required to move a couple additional integration
test preconditions into integration.Main (otherwise, the test would be
skipped due to the modified environment).

Updates golang/go#66636
Updates golang/go#66730

Change-Id: I24385474d4a6ebf6b7e9ae8f20948564bad3f55e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576135
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit c623a28)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577301
@irahardianto
Copy link
Author

Thanks for the tip, it rarely crash though, looking forward to the fix

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. 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