-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/telemetry-wins
Milestone
Description
#!stacks
"sigpanic" && "MetadataForFile:+1"
Issue created by stacks.
This stack InroIA was reported by telemetry:
// MetadataForFile returns a new slice containing metadata for each
// package containing the Go file identified by uri, ordered by the
// number of CompiledGoFiles (i.e. "narrowest" to "widest" package),
// and secondarily by IsIntermediateTestVariant (false < true).
// The result may include tests and intermediate test variants of
// importable packages.
// It returns an error if the context was cancelled.
func (s *Snapshot) MetadataForFile(ctx context.Context, uri protocol.DocumentURI) ([]*metadata.Package, error) {
if s.view.typ == AdHocView { <------- panicThere are several implicated derefs here: Snapshot.view, View.viewDefinition, viewDefinition.typ. I suspect the first one is the problem, as I can reproduce the crash by adding this patch and running the tests:
--- a/gopls/internal/server/command.go
+++ b/gopls/internal/server/command.go
@@ -1611,6 +1611,9 @@ func showDocumentImpl(ctx context.Context, cli protocol.Client, url protocol.URI
}
func (c *commandHandler) ChangeSignature(ctx context.Context, args command.ChangeSignatureArgs) (*protocol.WorkspaceEdit, error) {
+
+ args.Location.URI = ""
+which corresponds to a client providing a bad value in an RPC. That's a client bug (probably), but it shouldn't cause a server crash.
We should make commandHandler.run more defensive about a missing Snapshot.
crash/crashruntime.gopanic:+69runtime.panicmem:=262runtime.sigpanic:+19golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+1golang.org/x/tools/gopls/internal/golang.selectPackageForFile:+1golang.org/x/tools/gopls/internal/golang.NarrowestPackageForFile:+1golang.org/x/tools/gopls/internal/server.(*commandHandler).ChangeSignature.func1:+1golang.org/x/tools/gopls/internal/server.(*commandHandler).run.func2:+3golang.org/x/tools/gopls/internal/server.(*commandHandler).run:+81golang.org/x/tools/gopls/internal/server.(*commandHandler).ChangeSignature:+2golang.org/x/tools/gopls/internal/protocol/command.Dispatch:+45golang.org/x/tools/gopls/internal/server.(*server).ExecuteCommand:+28golang.org/x/tools/gopls/internal/protocol.serverDispatch:+674golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
golang.org/x/tools/gopls@v0.18.1 go1.23.7 darwin/arm64 neovim (2)
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/telemetry-wins