Skip to content

x/tools/gopls: crash in filepath.Walk during go.work completion #64225

Closed
@muse-jimmy

Description

@muse-jimmy

gopls version: v0.14.2 (go1.18rc1)
gopls flags:
update flags: proxy
extension version: 0.40.0
go version: 1.18rc1
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Fri, 17 Nov 2023 04:51:16 GMT
restart history:
Fri, 17 Nov 2023 03:37:10 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x10125b7cc]

goroutine 12 [running]:
golang.org/x/tools/gopls/internal/lsp/work.Completion.func1({0x14000786740, 0x39}, {0x0%3F, 0x0%3F}, {0x1400033f368%3F, 0x1400073ad60%3F})
	  completion.go:88  0x10c
path/filepath.walk({0x1400073ad60, 0xf}, {0x1016dcda8, 0x140003a4f70}, 0x140003b3368)
	  path.go:438  0x180
path/filepath.walk({0x1400090edc0, 0x8}, {0x1016dcda8, 0x140001e1ee0}, 0x140003b3368)
	  path.go:442  0x1fc
path/filepath.walk({0x101b9af38, 0x1}, {0x1016dcda8, 0x1400018a0d0}, 0x140003b3368)
	  path.go:442  0x1fc
path/filepath.Walk({0x101b9af38, 0x1}, 0x1400036d368)
	  path.go:505  0x70
golang.org/x/tools/gopls/internal/lsp/work.Completion({0x1016da058%3F, 0x140003624e0%3F}, {0x1016df9c8, 0x14000254140}, {0x1016dae58, 0x140006f0720}, {0xa4091900%3F, 0xc14dda2c%3F})
	  completion.go:76  0x40c
golang.org/x/tools/gopls/internal/lsp.(*Server).completion(0x140002a0640%3F, {0x1016da058, 0x140003624e0}, 0x140002a0640)
	  completion.go:44  0x2d0
golang.org/x/tools/gopls/internal/lsp.(*Server).Completion(0x140001c2240%3F, {0x1016d9fb0%3F, 0x1400040e300%3F}, 0x10156d080%3F)
	  server_gen.go:28  0x28
golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch({0x1016d9fb0, 0x1400040e300}, {0x1016e28a0, 0x1400011a2d0}, 0x14000362180, {0x1016da2c0, 0x1400040e200})
	  tsserver.go:269  0x187c
golang.org/x/tools/gopls/internal/lsp/protocol.ServerHandler.func1({0x1016d9fb0, 0x1400040e300}, 0x14000362180, {0x1016da2c0, 0x1400040e200})
	  protocol.go:157  0x70
golang.org/x/tools/gopls/internal/lsp/lsprpc.handshaker.func1({0x1016d9fb0, 0x1400040e300}, 0x14000362180, {0x1016da2c0%3F, 0x1400040e200%3F})
	  lsprpc.go:521  0x788
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1({0x1016d9fb0, 0x1400040e300}, 0x140002850e0, {0x1016da2c0%3F, 0x1400040e200%3F})
	  handler.go:35  0xf4
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2()
	  handler.go:103  0x90
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	  handler.go:100  0x1dc
[Error - 1:50:58 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>

Activity

changed the title [-]gopls: automated issue report (crash)[/-] [+]x/tools/gopls: crash in filepath.Walk during go.work completion[/+] on Nov 17, 2023
findleyr

findleyr commented on Nov 17, 2023

@findleyr
Member

Thanks for the report!

Looks like the WalkFunc at that location needs to check for non-nil err and/or nil FileInfo.
We should reproduce first (chmod a file in a regtest?), and then fix.

This seems like a relatively rare occurrence, so I think this is fine to just fix in the next release.

Since this is a gopls issue, transferring to the Go issue tracker.

transferred this issue fromgolang/vscode-goon Nov 17, 2023
added this to the gopls/v0.15.0 milestone on Nov 17, 2023
added
ToolsThis label describes issues relating to any tools in the x/tools repository.
goplsIssues related to the Go language server, gopls.
on Nov 17, 2023
self-assigned this
on Dec 15, 2023
gopherbot

gopherbot commented on Dec 15, 2023

@gopherbot
Contributor

Change https://go.dev/cl/550376 mentions this issue: gopls/internal/work: fix crash during go.work completion

added a commit that references this issue on Feb 5, 2024
f801f12
locked and limited conversation to collaborators on Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @gopherbot@findleyr@muse-jimmy

      Issue actions

        x/tools/gopls: crash in filepath.Walk during go.work completion · Issue #64225 · golang/go