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 during ast walk for semantic token #47964

Closed
michaelgrigoryan25 opened this issue Aug 25, 2021 · 8 comments
Closed

x/tools/gopls: panic during ast walk for semantic token #47964

michaelgrigoryan25 opened this issue Aug 25, 2021 · 8 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.
Milestone

Comments

@michaelgrigoryan25
Copy link

gopls version: v0.7.1
gopls flags:
update flags: proxy
extension version: 0.27.1
go version: 1.16.7
environment: Visual Studio Code win32
initialization error: undefined
manual restart count: 0
total start count: 1

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: invalid Pos value 10909176 (should be in [10908446, 10909175[)

goroutine 108163 [running]:
go/token.(*File).PositionFor(0xc00445b140, 0xa675f8, 0xc003d42a00, 0x0, 0x0, 0x0, 0x0, 0x0)
	C:/Program   position.go:349  0x1ab
golang.org/x/tools/internal/lsp.(*encoded).strStack(0xc0038310e0, 0xc0017c8060, 0xc003d42bd0)
	  semantic.go:239  0x31a
golang.org/x/tools/internal/lsp.(*encoded).unkIdent(0xc0038310e0, 0xc000f9dc40)
	  semantic.go:604  0x27d
golang.org/x/tools/internal/lsp.(*encoded).ident(0xc0038310e0, 0xc000f9dc40)
	  semantic.go:427  0xe1c
golang.org/x/tools/internal/lsp.(*encoded).inspector(0xc0038310e0, 0x17c7830, 0xc000f9dc40, 0xc001311f01)
	  semantic.go:343  0x32b
golang.org/x/tools/internal/lsp.(*encoded).semantics.func1(0x17c7830, 0xc000f9dc40, 0xc00106ba01)
	  semantic.go:129  0x45
go/ast.inspector.Visit(0xc001311fd0, 0x17c7830, 0xc000f9dc40, 0x17c4a20, 0xc001311fd0)
	C:/Program   walk.go:373  0x42
go/ast.Walk(0x17c4a20, 0xc001311fd0, 0x17c7830, 0xc000f9dc40)
	C:/Program   walk.go:52  0x6a
go/ast.Walk(0x17c4a20, 0xc001311fd0, 0x17c7740, 0xc001525900)
	C:/Program   walk.go:270  0x78e
go/ast.walkStmtList(0x17c4a20, 0xc001311fd0, 0xc00106b900, 0x1, 0x1)
	C:/Program   walk.go:32  0xa5
go/ast.Walk(0x17c4a20, 0xc001311fd0, 0x17c73f8, 0xc001716030)
	C:/Program   walk.go:224  0x1988
go/ast.Walk(0x17c4a20, 0xc001311fd0, 0x17c7a10, 0xc0039ce5a0)
	C:/Program   walk.go:285  0x2765
go/ast.walkStmtList(0x17c4a20, 0xc001311fd0, 0xc001525a00, 0x3, 0x4)
	C:/Program   walk.go:32  0xa5
go/ast.Walk(0x17c4a20, 0xc001311fd0, 0x17c73f8, 0xc001716060)
	C:/Program   walk.go:224  0x1988
go/ast.Walk(0x17c4a20, 0xc001311fd0, 0x17c7768, 0xc001716090)
	C:/Program   walk.go:344  0xd06
go/ast.Inspect(...)
	C:/Program   walk.go:385
golang.org/x/tools/internal/lsp.(*encoded).semantics(0xc0038310e0)
	  semantic.go:137  0x3be
golang.org/x/tools/internal/lsp.(*Server).computeSemanticTokens(0xc00044d9e0, 0x17d59d8, 0xc001634e00, 0xc0047e4840, 0x3a, 0x0, 0x0, 0x0, 0x0)
	  semantic.go:116  0x4c5
golang.org/x/tools/internal/lsp.(*Server).semanticTokensFull(...)
	  semantic.go:34
golang.org/x/tools/internal/lsp.(*Server).SemanticTokensFull(0xc00044d9e0, 0x17d59d8, 0xc001634e00, 0xc002eeb7d0, 0xc002eeb7d0, 0x0, 0x0)
	  server_gen.go:212  0x65
golang.org/x/tools/internal/lsp/protocol.serverDispatch(0x17d59d8, 0xc001634e00, 0x17ed340, 0xc00044d9e0, 0xc002eeb740, 0x17d5c40, 0xc001634d80, 0x1691001, 0x0, 0x17c4440)
	  tsserver.go:274  0x6825
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1(0x17d59d8, 0xc001634e00, 0xc002eeb740, 0x17d5c40, 0xc001634d80, 0x0, 0xc041af9c3030f16c)
	  protocol.go:154  0xc7
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1(0x17d59d8, 0xc001634e00, 0xc002eeb740, 0x17d5c40, 0xc001634d80, 0x0, 0x0)
	  lsprpc.go:506  0x459
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1(0x17d59d8, 0xc001634e00, 0xc0012ec7e0, 0x17d5c40, 0xc001634d80, 0x13a8e00, 0x10000c001f80668)
	  handler.go:35  0xe2
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0xc0037ab200, 0xc001d73740, 0xc0001f4380, 0x17d59d8, 0xc001634e00, 0xc0012ec7e0, 0x17d5c40, 0xc001634d80)
	  handler.go:103  0x8d
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	  handler.go:100  0x179
[Error - 5:34:40 PM] 
@hyangah
Copy link
Contributor

hyangah commented Aug 25, 2021

Thanks for the report @michaelgrigoryan25
By any chance, do you have any repro case for us to use while developing a fix? (e.g. public repo)

@pjweinb @findleyr @stamblerre : should we use a similar approach used to handle #47231 should be used in the semantic token?

Transferring to gopls.

@hyangah hyangah changed the title gopls: automated issue report (crash) x/tools/gopls: panic during ast walk for semantic token Aug 25, 2021
@hyangah hyangah transferred this issue from golang/vscode-go Aug 25, 2021
@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 25, 2021
@gopherbot gopherbot added this to the Unreleased milestone Aug 25, 2021
@hyangah hyangah modified the milestones: Unreleased, gopls/v0.7.2 Aug 25, 2021
@michaelgrigoryan25
Copy link
Author

Hey @hyangah, thanks for your response.
Yes, the repo is public and is available via this link: https://github.com/michaelgrigoryan25/mathgo

@pjweinb
Copy link

pjweinb commented Aug 25, 2021 via email

@pjweinb pjweinb self-assigned this Aug 25, 2021
@michaelgrigoryan25
Copy link
Author

I can't say for sure, sorry about that 😕

@pjweinb
Copy link

pjweinb commented Aug 25, 2021 via email

@hyangah
Copy link
Contributor

hyangah commented Aug 26, 2021

Thanks @pjweinb

@michaelgrigoryan25 Can you install gopls with the following command from a directory outside any module (e.g. /tmp or your home directory :-) ) and verify if that works?

GO111MODULE=on go get golang.org/x/tools/gopls@master golang.org/x/tools@master

@michaelgrigoryan25
Copy link
Author

michaelgrigoryan25 commented Aug 26, 2021

Sure! Will do it after I get home. Thanks for trying to help 🙂

Edit: I've installed it

@pjweinb
Copy link

pjweinb commented Sep 4, 2021

fixed in latest release

@pjweinb pjweinb closed this as completed Sep 4, 2021
@rsc rsc unassigned pjweinb Jun 23, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
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

4 participants