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: slice bounds out of range error during typerefs.Decode #62383

Closed
siamkiw opened this issue Aug 30, 2023 · 5 comments
Assignees
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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@siamkiw
Copy link

siamkiw commented Aug 30, 2023

gopls version: v0.13.2 (go1.19.4)
gopls flags:
update flags: proxy
extension version: 2023.8.1617
go version: 1.19.4
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Wed, 30 Aug 2023 09:56:11 GMT
restart history:
Wed, 30 Aug 2023 09:55:46 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: runtime error: slice bounds out of range [:1728708865] with capacity 504

goroutine 3780 [running]:
golang.org/x/tools/gopls/internal/lsp/frob.(*reader).bytes(...)
	  frob.go:404
golang.org/x/tools/gopls/internal/lsp/frob.(*frob).decode(0x1400007fad0, 0x140040c5840, {0x1038d2300%3F, 0x14004306000%3F, 0x14000a441c8%3F})
	  frob.go:362  0xfc8
golang.org/x/tools/gopls/internal/lsp/frob.(*frob).decode(0x1400007faa0, 0x140e4b9f840, {0x1038c5fc0%3F, 0x14002605d10%3F, 0x104208108%3F})
	  frob.go:324  0x101c
golang.org/x/tools/gopls/internal/lsp/frob.(*frob).decode(0x1400027b470, 0x140e4b9f840, {0x10395fba0%3F, 0x14002605d10%3F, 0xe380%3F})
	  frob.go:367  0xf80
golang.org/x/tools/gopls/internal/lsp/frob.(*frob).Decode(0x1400027b470, {0x140021c3e00, 0xb3, 0x200}, {0x1038b06e0%3F, 0x14002605d10%3F})
	  frob.go:258  0x1a8
golang.org/x/tools/gopls/internal/lsp/source/typerefs.decode(0x140002b86e0%3F, {0x103a246d8%3F, 0x140042632c0%3F}, {0x140021c3e00, 0xb3, 0x200})
	  refs.go:806  0x6c
golang.org/x/tools/gopls/internal/lsp/source/typerefs.Decode(...)
	  refs.go:42
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).typerefs(0x140002b86e0, {0x103a246d8, 0x140042632c0}, 0x14000341200, {0x103fc4098, 0x0, 0x0})
	  check.go:1224  0x188
golang.org/x/tools/gopls/internal/lsp/cache.(*packageHandleBuilder).buildPackageHandle(0x1400290d380, {0x103a246d8, 0x140042632c0}, 0x140003fba40)
	  check.go:1082  0x1c8
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func2.1()
	  check.go:891  0xb0
golang.org/x/sync/errgroup.(*Group).Go.func1()
	  errgroup.go:75  0x5c
created by golang.org/x/sync/errgroup.(*Group).Go
	  errgroup.go:72  0xa4
[Error - 4:55:53 PM] 

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
Copy link
Contributor

CC @adonovan

@hyangah hyangah changed the title gopls: automated issue report (crash) x/tools/gopls/internal/lsp: slice bounds out of range error during typerefs.Decode Aug 30, 2023
@adonovan adonovan self-assigned this Aug 30, 2023
@adonovan adonovan transferred this issue from golang/vscode-go Aug 30, 2023
@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 Aug 30, 2023
@gopherbot gopherbot added this to the Unreleased milestone Aug 30, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/524655 mentions this issue: gopls/internal/lsp/frob: add defensive header

gopherbot pushed a commit to golang/tools that referenced this issue Aug 31, 2023
I can't explain the crash in the bug report: the frob logic
looks sound, which leaves these possibilities:
(a) the provided data is garbage or is being trampled
    (but the caller logic looks sound);
(b) the file contents are corrupted (but the filecache
    SHA256 checksum was fine);
(c) there's a RAM problem (but that always feels like
    a cop-out explanation).

I've added a magic number to the file header so that there's
a chance we'll detect some variants of a and b.

Updates golang/go#62383

Change-Id: Icd32a2dc6ab019f3deee1b332428e0313c93a6ff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/524655
Run-TryBot: Alan Donovan <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
@adonovan
Copy link
Member

adonovan commented Aug 31, 2023

Thanks for reporting this; it's very mysterious. How often have you observed it? I added an assertion that may help diagnose the cause. If you are able to reproduce this crash readily, please try reinstalling gopls from master:

$ git clone https://go.googlesource.com/tools & cd tools
$ go install ./gopls
$ killall gopls

Do let us know what you find.

@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 1, 2023
@hyangah hyangah modified the milestones: Unreleased, gopls/v0.14.0 Sep 1, 2023
@findleyr
Copy link
Contributor

Has this reoccurred? If not, we don't have much to go on, and are unlikely to be able to root cause the issue here.

Bumping to v0.15 to keep on our radar.

@findleyr findleyr modified the milestones: gopls/v0.14.0, gopls/v0.15.0 Sep 27, 2023
@gopherbot
Copy link
Contributor

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 1, 2023
@golang golang locked and limited conversation to collaborators Sep 30, 2024
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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants