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: crash when primary diagnostics have invalid positions #66731

Closed
czlingo opened this issue Apr 8, 2024 · 2 comments
Closed

x/tools/gopls: crash when primary diagnostics have invalid positions #66731

czlingo opened this issue Apr 8, 2024 · 2 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

@czlingo
Copy link

czlingo commented Apr 8, 2024

gopls version: v0.15.2/go1.22.0
gopls flags:
update flags: proxy
extension version: 0.41.2
environment: Visual Studio Code linux
initialization error: undefined
issue timestamp: Mon, 08 Apr 2024 02:53:47 GMT
restart history:
Wed, 03 Apr 2024 01:36:12 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: runtime error: index out of range [0] with length 0

goroutine 2303 [running]:
golang.org/x/tools/gopls/internal/cache.typeErrorsToDiagnostics.func1({0xc00070cc00, 0x8, 0x41c078%3F})
	  check.go:1915  0xe65
golang.org/x/tools/gopls/internal/cache.typeErrorsToDiagnostics(0x0%3F, {0xc002201b08%3F, 0xc000375040%3F, 0x46%3F}, {0xfd5f19%3F, 0x4%3F}, 0x0%3F, 0x1b%3F)
	  check.go:1940  0x18a
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).checkPackage(0xc002c65da0, {0x1293e08, 0xc001aafe00}, 0xc0006a39e0)
	  check.go:1587  0xeeb
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage(0xc002c65da0, {0x1293e08, 0xc001aafe00}, 0x0, {0xc0006ed890, 0x22})
	  check.go:563  0x5e5
golang.org/x/tools/gopls/internal/cache.(*Snapshot).forEachPackageInternal.func2()
	  check.go:414  0x2b
golang.org/x/sync/errgroup.(*Group).Go.func1()
	  errgroup.go:78  0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 90
	  errgroup.go:75  0x96
gopls stats -anon { "DirStats": { "Files": 274, "TestdataFiles": 0, "GoFiles": 270, "ModFiles": 1, "Dirs": 94 }, "GOARCH": "amd64", "GOOS": "linux", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.22.0", "GoplsVersion": "v0.15.2", "InitialWorkspaceLoadDuration": "511.819507ms", "MemStats": { "HeapAlloc": 30673448, "HeapInUse": 53641216, "TotalAlloc": 386990840 }, "WorkspaceStats": { "Files": { "Total": 1262, "Largest": 395026, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.0", "AllPackages": { "Packages": 244, "LargestPackage": 161, "CompiledGoFiles": 1270, "Modules": 9 }, "WorkspacePackages": { "Packages": 89, "LargestPackage": 31, "CompiledGoFiles": 283, "Modules": 1 }, "Diagnostics": 348 } ] } }

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: crash when primary diagnostics have invalid positions Apr 8, 2024
@findleyr findleyr transferred this issue from golang/vscode-go Apr 8, 2024
@findleyr findleyr self-assigned this Apr 8, 2024
@findleyr findleyr added this to the gopls/v0.15.3 milestone Apr 8, 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 8, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/577259 mentions this issue: gopls/internal/cache: avoid panic when the primary diagnostic is broken

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/577303 mentions this issue: [gopls-release-branch.0.15] gopls/internal/cache: avoid panic when the primary diagnostic is broken

gopherbot pushed a commit to golang/tools that referenced this issue Apr 8, 2024
…e primary diagnostic is broken

If the primary diagnostic has invalid position information (due to a bug
in the parser or AST fix logic), gopls may panics when linking primary
and related information. Avoid this panic.

Updates golang/go#66731
Updates golang/go#66730

Change-Id: Ie2f95d158a1c93d00603a7ce4d38d8097bd8cb08
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577259
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
(cherry picked from commit f41d27e)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577303
Auto-Submit: Robert Findley <rfindley@google.com>
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