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 in span.ToOffset (incorrect boundary condition) #54006

Closed
zipp83 opened this issue Jul 20, 2022 · 3 comments
Closed

x/tools/gopls: crash in span.ToOffset (incorrect boundary condition) #54006

zipp83 opened this issue Jul 20, 2022 · 3 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.
Milestone

Comments

@zipp83
Copy link

zipp83 commented Jul 20, 2022

gopls version: v0.9.1 (unknown)
gopls flags:
update flags: proxy
extension version: 0.34.1
go version: unknown
environment: Visual Studio Code linux
initialization error: undefined
issue timestamp: Sun, 17 Jul 2022 19:35:51 GMT
restart history:
Sun, 17 Jul 2022 19:34:40 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: invalid line number 0 (should be >= 1)

goroutine 418 [running]:
go_1token.File.LineStart
	:0
golang_0org_1x_1tools_1internal_1span.ToOffset
	  token.go:183
golang_0org_1x_1tools_1internal_1span.point.updateOffset
	  span.go:271
golang_0org_1x_1tools_1internal_1span.Span.update
	  span.go:253
golang_0org_1x_1tools_1internal_1span.Span.WithAll
	  span.go:227
golang_0org_1x_1tools_1internal_1lsp_1protocol.ColumnMapper.Range
	  span.go:58
golang.org/x/tools/internal/lsp/cache.spanToRange
	  errors.go:362
golang.org/x/tools/internal/lsp/cache.goPackagesErrorDiagnostics
	  errors.go:61
golang.org/x/tools/internal/lsp/cache.typeCheck
	  check.go:363
golang.org/x/tools/internal/lsp/cache.snapshot.buildPackageHandle..func1
	  check.go:125
golang.org/x/tools/internal/memoize.Handle.run..func2
	  memoize.go:407
runtime_1trace.WithRegion
	:0
golang.org/x/tools/internal/memoize.Handle.run..func1
	  memoize.go:400
__start_context
	:0
created by golang_0org_1x_1tools_1internal_1memoize.Handle.run
	  memoize.go:399  0x221
[Error - 10:35:46 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>

@jamalc
Copy link

jamalc commented Jul 22, 2022

Thanks for the report. Can you please share the log you see in the gopls output channel and tell us when you observed this popup (e.g. I was updating gopls, I just opened the vscode, I did refactoring, ...)?
106151310-3899a680-614a-11eb-9be7-42f2ae0592c9

@jamalc jamalc added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 22, 2022
@findleyr
Copy link
Contributor

Looking at this stack, there is clearly a bug that we're not checking the right boundary condition for the line offset.

This code has changed recently, but I believe only in trivial ways.

Nevertheless, I will try to reproduce and fix.

@hyangah hyangah transferred this issue from golang/vscode-go Jul 22, 2022
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jul 22, 2022
@hyangah hyangah changed the title gopls: automated issue report (crash) x/tools/gopls: automated issue report (crash) Jul 22, 2022
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jul 22, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jul 22, 2022
@findleyr findleyr changed the title x/tools/gopls: automated issue report (crash) x/tools/gopls: crash in span.ToOffset (incorrect boundary condition) Jul 22, 2022
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.9.2 Jul 22, 2022
@findleyr findleyr removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 22, 2022
@gopherbot
Copy link

Change https://go.dev/cl/419109 mentions this issue: internal/span: fix incorrect bounds check in ToOffset

@findleyr findleyr self-assigned this Aug 8, 2022
@golang golang locked and limited conversation to collaborators Aug 8, 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