Skip to content

x/tools/gopls: nil deref in DidCreateFiles on result of call to completion.NewFile #74057

Closed
@adonovan

Description

@adonovan
#!stacks
"sigpanic" && "server.(*server).DidCreateFiles:+20"

Issue created by stacks.

// NewFile returns a document change to complete an empty go file.
func NewFile(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle) (*protocol.DocumentChange, error) {
	if bs, err := fh.Content(); err != nil || len(bs) != 0 {
		return nil, err <----------- may return no result and no error
	}
	meta, err := snapshot.NarrowestMetadataForFile(ctx, fh.URI())
	if err != nil {
		return nil, err
	}

@xieyuschen

This stack WhZjCw was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 darwin/arm64 vscode (2)
golang.org/x/tools/gopls@v0.19.0-pre.1 go1.24.3 darwin/arm64 other (9)
golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 darwin/arm64 other (1)

Dups: 6JFvKA DO30IQ

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone 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.goplsIssues related to the Go language server, gopls.gopls/telemetry-wins

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions