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

gopls: crash in gopls@v0.15.0 highlighting return values of functions with no results (fixed in v0.15.1) #3194

Closed
timoffex opened this issue Feb 27, 2024 · 5 comments
Milestone

Comments

@timoffex
Copy link

gopls version: v0.15.0/go1.21.6
gopls flags:
update flags: proxy
extension version: 0.41.1
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Mon, 26 Feb 2024 23:28:43 GMT
restart history:
Mon, 26 Feb 2024 23:24:50 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

I was defining a new method and got a notification that gopls crashed. The crash is very consistent and happens after I type out "new*" as below, press backspace once or twice, and press Escape to exit the Vim extension's insert mode.

// ... more code above
func (tracker *RateLimitTracker) interp(old float64, new float64) {
	return new*|  // <- cursor at the bar
}
// ... more code below

Please attach the stack trace from the crash.
A window with the error message should have popped up in the lower half of your screen.
Please copy the stack trace and error messages from that window and paste it in this issue.

[Error - 3:28:42 PM] Request textDocument/semanticTokens/full failed.
  Message: semantictokens are disabled
  Code: 0 
[Error - 3:28:42 PM] Request textDocument/semanticTokens/range failed.
  Message: semantictokens are disabled
  Code: 0 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x102b6d9b0]

goroutine 2883 [running]:
golang.org/x/tools/gopls/internal/golang.highlightFuncControlFlow({0x14002a6a480, 0x5, 0x8?}, 0x140007c8930)
	/Users/timoffex/go/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/golang/highlight.go:241 +0x350
golang.org/x/tools/gopls/internal/golang.highlightPath({0x14002a6a480, 0x5, 0x8}, 0x140009b63c0?, 0x14000564000)
	/Users/timoffex/go/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/golang/highlight.go:102 +0x274
golang.org/x/tools/gopls/internal/golang.Highlight({0x103212928?, 0x14003aaa8a0?}, 0x14002ab8120?, {0x103213be0, 0x14002ab8120}, {0x5143c0?, 0x140?})
	/Users/timoffex/go/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/golang/highlight.go:53 +0x208
golang.org/x/tools/gopls/internal/server.(*server).DocumentHighlight(0x140005143c0?, {0x103212960, 0x14003e2c730}, 0x14003aaa690)
	/Users/timoffex/go/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/server/highlight.go:32 +0x198
golang.org/x/tools/gopls/internal/protocol.serverDispatch({0x103212960, 0x14003e2c730}, {0x103223d08, 0x14000324100}, 0x14003aaa660, {0x103212b20, 0x14001bda300})
	/Users/timoffex/go/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/protocol/tsserver.go:376 +0x4dd8
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3({0x103212960, 0x14003e2c730}, 0x14003aaa660, {0x103212b20, 0x14001bda300})
	/Users/timoffex/go/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/protocol/protocol.go:160 +0x74
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4({0x103212960, 0x14003e2c730}, 0x14003aaa660, {0x103212b20?, 0x14001bda300?})
	/Users/timoffex/go/pkg/mod/golang.org/x/tools/gopls@v0.15.0/internal/lsprpc/lsprpc.go:509 +0x6d0
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1({0x103212960, 0x14003e2c730}, 0x140034cf440, {0x103212b20?, 0x14001bda300?})
	/Users/timoffex/go/pkg/mod/golang.org/x/tools@v0.18.1-0.20240221145400-a220b3b5ba60/internal/jsonrpc2/handler.go:35 +0xdc
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2()
	/Users/timoffex/go/pkg/mod/golang.org/x/tools@v0.18.1-0.20240221145400-a220b3b5ba60/internal/jsonrpc2/handler.go:103 +0x90
created by golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2 in goroutine 162
	/Users/timoffex/go/pkg/mod/golang.org/x/tools@v0.18.1-0.20240221145400-a220b3b5ba60/internal/jsonrpc2/handler.go:100 +0x1d0
[Error - 3:28:43 PM] 

Failed to auto-collect gopls trace: incomplete panic trace.

gopls stats -anon { "DirStats": { "Files": 176805, "TestdataFiles": 8, "GoFiles": 140, "ModFiles": 3, "Dirs": 22615 }, "GOARCH": "arm64", "GOOS": "darwin", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.21.6", "GoplsVersion": "v0.15.0", "InitialWorkspaceLoadDuration": "58.183208ms", "MemStats": { "HeapAlloc": 3688760, "HeapInUse": 6807552, "TotalAlloc": 46907088 }, "WorkspaceStats": { "Files": { "Total": 0, "Largest": 0, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.21.6", "AllPackages": { "Packages": 0, "LargestPackage": 0, "CompiledGoFiles": 0, "Modules": 0 }, "WorkspacePackages": { "Packages": 0, "LargestPackage": 0, "CompiledGoFiles": 0, "Modules": 0 }, "Diagnostics": 0 } ] } }

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>

@gopherbot gopherbot added this to the Untriaged milestone Feb 27, 2024
@findleyr
Copy link
Contributor

Thank you for reporting. This is also reported as golang/go#65952.

This will be fixed today, and we will cut v0.15.1 with the fix soon (most likely today or tomorrow).

@findleyr findleyr changed the title gopls: automated issue report (crash) gopls: crash highlighting return values of functions with no results Feb 27, 2024
@findleyr
Copy link
Contributor

This is fixed in the next prerelease:

go install golang.org/x/tools/gopls@v0.15.1-pre.1

@findleyr
Copy link
Contributor

We'll release the fix as v0.15.1 tomorrow. Given that this crash only occurs with invalid code (a return value without a corresponding result parameter), we decided to wait one more day in case there are additional crash patterns reported. Nevertheless, I can see how this crash would be relatively easy to encounter, so we want to release the fix soon.

@aaomidi
Copy link

aaomidi commented Feb 28, 2024

The pre-release solves this problem for me too.

@findleyr
Copy link
Contributor

Gopls v0.15.1 is released, with a fix: https://github.com/golang/tools/releases/tag/gopls%2Fv0.15.1

go install golang.org/x/tools/gopls@v0.15.1

Leaving this open for today, for visibility.

@findleyr findleyr changed the title gopls: crash highlighting return values of functions with no results gopls: crash in gopls@v0.15.0 highlighting return values of functions with no results (fixed in v0.15.1) Feb 28, 2024
@suzmue suzmue modified the milestones: Untriaged, v0.42.0 Feb 28, 2024
@suzmue suzmue closed this as completed Feb 29, 2024
@hyangah hyangah unpinned this issue Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants