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: "unexpected files in command-line-arguments package" bug (via telemetry) #64557

Open
adonovan opened this issue Dec 5, 2023 · 40 comments
Assignees
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Dec 5, 2023

#!stacks
"bug.Reportf" &&
  ("cache.buildMetadata:+19" ||
   "cache.buildMetadata:+16" && !"buildMetadata:+166" /* sigh; see #71045 */ || 
   "cache.buildMetadata:+14")

Yay! Repro at #64557 (comment)

This stacks EVz2Fg, ELG5Yw, ND0D7A were reported by telemetry:

// buildMetadata populates the updates map with metadata updates to
// apply, based on the given pkg. It recurs through pkg.Imports to ensure that
// metadata exists for all dependencies.
func buildMetadata(updates map[PackageID]*metadata.Package, pkg *packages.Package, loadDir string, standalone bool) {
	// Allow for multiple ad-hoc packages in the workspace (see #47584).
	pkgPath := PackagePath(pkg.PkgPath)
	id := PackageID(pkg.ID)

	if metadata.IsCommandLineArguments(id) {
		if len(pkg.CompiledGoFiles) != 1 {
			bug.Reportf("unexpected files in command-line-arguments package: %v", pkg.CompiledGoFiles)
			return
gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:7
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).load:173
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/lsp/source.NarrowestMetadataForFile:1
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseChangedFiles:28
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseSnapshot:25
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseSnapshots.func1:2
runtime.goexit:0
golang.org/x/tools/[email protected] go1.21.0 darwin/arm64 (6)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

Duplicates:

This stack dDf6yw was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:7
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).load:173
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/lsp/source.selectPackageForFile:1
golang.org/x/tools/gopls/internal/lsp/source.NarrowestPackageForFile:1
golang.org/x/tools/gopls/internal/lsp/source.SignatureHelp:6
golang.org/x/tools/gopls/internal/lsp.(*Server).signatureHelp:9
golang.org/x/tools/gopls/internal/lsp.(*Server).SignatureHelp:1
golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch:490
golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3:5
golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4:52
golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1:2
golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2.2:3
runtime.goexit:0
golang.org/x/tools/[email protected] go1.21.6 windows/amd64 vscode (1)

This stack Es6nFQ was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:7
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:143
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).load:173
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/lsp/source.NarrowestMetadataForFile:1
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseChangedFiles:28
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseSnapshot:25
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseSnapshots.func1:2
runtime.goexit:0
golang.org/x/tools/[email protected] go1.21.3 darwin/arm64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

This stack OBhdqw was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:7
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:143
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).load:173
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/lsp/source.NarrowestMetadataForFile:1
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).ListImports.func1:25
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).run.func1:2
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).run:72
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).ListImports:2
golang.org/x/tools/gopls/internal/lsp/command.Dispatch:73
golang.org/x/tools/gopls/internal/lsp.(*Server).executeCommand:19
golang.org/x/tools/gopls/internal/lsp.(*Server).ExecuteCommand:1
golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch:606
golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3:5
golang.org/x/tools/[email protected] go1.21.3 darwin/arm64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

Dups: gRw1-A ibW47g Dfhd-g _p1kkQ RcEuHA fJJ7HA e0uUFg 9M1npA WNZ--Q SmQ1mg v1Eb2g DdP2cQ 5Um4Rg yWpCHQ ziMhMQ 49eF6g rAKLNA bm9HIg EOWgnA ajbd5g 4Kmr1A ztITlA LmpcWQ daD0Wg NrjaNg ci33qA iVSJBQ bune9w xVlXmw IGBQ2g

@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. gopls/telemetry-wins labels Dec 5, 2023
@gopherbot gopherbot added this to the Unreleased milestone Dec 5, 2023
@hyangah hyangah modified the milestones: Unreleased, gopls/v0.15.0 Dec 7, 2023
@adonovan
Copy link
Member Author

adonovan commented Feb 2, 2024

Apparently one can create a command-line-arguments package with zero CompiledGoFiles:

xtools$ echo "" > b.go
xtools$ go list -e  -compiled -json  ./b.go
{
	"Dir": "/Users/adonovan/w/xtools",
	"ImportPath": "command-line-arguments",
	"Match": [
		"./b.go"
	],
	"Incomplete": true,
	"Stale": true,
	"StaleReason": "build ID mismatch",
	"GoFiles": [
		"b.go"
	],
	"InvalidGoFiles": [
		"b.go"
	],
	"Error": {
		"ImportStack": [
			"command-line-arguments"
		],
		"Pos": "b.go:1:2",
		"Err": "expected 'package', found 'EOF'"
	}
}

@adonovan adonovan self-assigned this Feb 2, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/560465 mentions this issue: gopls/internal/cache: allow command-line-package >1 CompileGoFiles

@adonovan
Copy link
Member Author

This stack ibW47g was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:7
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:143
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).load:173
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).resolveImportGraph:11
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getImportGraph.func1:2
runtime.goexit:0
golang.org/x/tools/[email protected] devel windows/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

adonovan commented Feb 27, 2024

This stack gRw1-A was reported by telemetry:

buildMetadata:14 is:

bug.Reportf("unexpected files in command-line-arguments package: %v", pkg.CompiledGoFiles)
gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:35
golang.org/x/tools/gopls/internal/util/bug.Reportf:1
golang.org/x/tools/gopls/internal/cache.buildMetadata:14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/cache.(*Snapshot).resolveImportGraph:11
golang.org/x/tools/gopls/internal/cache.(*Snapshot).getImportGraph.func1:2
runtime.goexit:0
golang.org/x/tools/[email protected] go1.22rc1 linux/amd64 vscodium (2)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

adonovan commented Mar 5, 2024

Reopening due to new field reports at v0.15.

@adonovan adonovan reopened this Mar 5, 2024
@adonovan
Copy link
Member Author

This stack _p1kkQ was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.buildMetadata:+156
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.NarrowestMetadataForFile:+1
golang.org/x/tools/gopls/internal/server.(*commandHandler).ListImports.func1:+25
golang.org/x/tools/gopls/internal/server.(*commandHandler).run.func2:+3
golang.org/x/tools/gopls/internal/server.(*commandHandler).run:+68
golang.org/x/tools/gopls/internal/server.(*commandHandler).ListImports:+2
golang.org/x/tools/gopls/internal/protocol/command.Dispatch:+79
golang.org/x/tools/gopls/internal/server.(*server).ExecuteCommand:+19
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+674
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/[email protected] go1.22.0 darwin/arm64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

This stack RcEuHA was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.buildMetadata:+156
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.selectPackageForFile:+1
golang.org/x/tools/gopls/internal/golang.NarrowestPackageForFile:+1
golang.org/x/tools/gopls/internal/golang.CodeActions:+65
golang.org/x/tools/gopls/internal/server.(*server).CodeAction:+95
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+160
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/[email protected] go1.22.1 linux/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

This stack fJJ7HA was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.NarrowestMetadataForFile:+1
golang.org/x/tools/gopls/internal/server.(*server).diagnoseChangedFiles:+33
golang.org/x/tools/gopls/internal/server.(*server).diagnoseSnapshot:+27
golang.org/x/tools/gopls/internal/server.(*server).diagnoseChangedViews.func1:+3
runtime.goexit:+0
golang.org/x/tools/[email protected] go1.21.8 darwin/arm64 other,vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

This stack e0uUFg was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/cache.(*Snapshot).orphanedFileDiagnostics:+13
golang.org/x/tools/gopls/internal/cache.(*Session).OrphanedFileDiagnostics:+50
golang.org/x/tools/gopls/internal/server.(*server).diagnoseChangedViews:+54
golang.org/x/tools/gopls/internal/server.(*server).didModifyFiles.func2:+1
runtime.goexit:+0
golang.org/x/tools/[email protected] go1.22.1 linux/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

adonovan commented Apr 2, 2024

This stack 9M1npA was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.NarrowestMetadataForFile:+1
golang.org/x/tools/gopls/internal/server.goLinks:+16
golang.org/x/tools/gopls/internal/server.(*server).DocumentLink:+14
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+291
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/[email protected] go1.22.1 linux/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

adonovan commented Apr 2, 2024

This stack WNZ--Q was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.selectPackageForFile:+1
golang.org/x/tools/gopls/internal/golang.NarrowestPackageForFile:+1
golang.org/x/tools/gopls/internal/golang.Highlight:+6
golang.org/x/tools/gopls/internal/server.(*server).DocumentHighlight:+14
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+280
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/[email protected] go1.22.1 linux/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

This stack SmQ1mg was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.NarrowestMetadataForFile:+1
golang.org/x/tools/gopls/internal/golang.Format:+47
golang.org/x/tools/gopls/internal/server.(*server).Formatting:+14
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+324
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/[email protected] go1.22.2 linux/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan adonovan modified the milestones: gopls/v0.15.0, gopls/v0.16.0 May 17, 2024
@adonovan
Copy link
Member Author

27 reported crashes this week... I really need to make some progress on this one.

@adonovan
Copy link
Member Author

The bug indicates that there are multiple .go files in a command-line-arguments package. This is perfectly valid for go list a.go b.go when multiple .go files (and only .go files) are given as argument patterns, but it should never happen in gopls. Gopls has only one call to packages.Load, in Snapshot.load, and its query arguments come from the loop over scopes, which asserts that if there is a fileLoadScope (file=foo.go), then it must be the sole one.

Crazy thought: Is it possible for strings of the form "*.go" or "file=foo.go" to arise from the other kinds of scopes? If so, it would have to be a packageLoadScope; the others all have other suffixes. These strings are created in reloadWorkspace, from the PkgPath values in the shouldLoadRange map. They all originate from Metadata.PkgPath and Metadata.ForTest. Is it possible for a PkgPath to end in .go? Yes (see below). Is this common? Very much not.

So I think the answer must lie in go list. Perhaps @matloob has some insight.

xtools$ cat h.go/h.go 
package ff
xtools$ go list -json ./h.go
{
	"Dir": "/Users/adonovan/w/xtools/h.go",
	"ImportPath": "golang.org/x/tools/h.go",
	"Name": "ff",
	"Root": "/Users/adonovan/w/xtools",
	"Module": {
		"Path": "golang.org/x/tools",
		"Main": true,
		"Dir": "/Users/adonovan/w/xtools",
		"GoMod": "/Users/adonovan/w/xtools/go.mod",
		"GoVersion": "1.19"
	},
	"Match": [
		"./h.go"
	],
	"Stale": true,
	"StaleReason": "build ID mismatch",
	"GoFiles": [
		"h.go"
	]
}

@adonovan
Copy link
Member Author

This stack v1Eb2g was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.selectPackageForFile:+1
golang.org/x/tools/gopls/internal/golang.NarrowestPackageForFile:+1
golang.org/x/tools/gopls/internal/golang.CodeActions:+65
golang.org/x/tools/gopls/internal/server.(*server).CodeAction:+95
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+160
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/[email protected] go1.22.0 darwin/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@findleyr findleyr modified the milestones: gopls/v0.16.0, gopls/v0.17.0 Jun 4, 2024
@siddharthab
Copy link
Contributor

siddharthab commented Sep 20, 2024

Hi @adonovan, thank you for keeping this issue open and continuing to investigate.

I was hitting an issue with gopls and traced it down to this bug. A second compiled Go file comes from CGo in my case. Reproduction is fairly simple. Filed it as #69564.

@findleyr
Copy link
Member

@siddharthab brilliant, your example reproduces this bug:

> cat main.go
//go:build ignore

package main

import (
        "C"
        "fmt"
)

func main() {
        fmt.Println("hello")
}

> gopackages -json main.go
{
        "ID": "command-line-arguments",
        "Name": "main",
        "PkgPath": "command-line-arguments",
        "GoFiles": [
                "/usr/local/google/home/rfindley/tmp/issue69564/main.go"
        ],
        "CompiledGoFiles": [
                "/usr/local/google/home/rfindley/.cache/go-build/4f/4f33c431ad5b11b8412d2953424eba9d58dbf1d77b3e1615678c780818d41a90-d",
                "/usr/local/google/home/rfindley/.cache/go-build/1f/1fd9171548b0ac0469be2115b2cc31122dcc5b856ff816129e0ff63e07d514e6-d",
                "/usr/local/google/home/rfindley/.cache/go-build/79/79bea79feab5807a48466230c80ae7822f4276a69f3abb41d051d784aa1552e9-d"
        ],
        "Imports": {
                "fmt": "fmt",
                "runtime/cgo": "runtime/cgo",
                "syscall": "syscall",
                "unsafe": "unsafe"
        }
}

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/627776 mentions this issue: gopls/internal/cache: id command-line-arguments packages using GoFiles

@findleyr findleyr assigned findleyr and unassigned adonovan Nov 14, 2024
@findleyr findleyr added the FixPending Issues that have a fix which has not yet been reviewed or submitted. label Nov 14, 2024
@adonovan
Copy link
Member Author

This stack LmpcWQ was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.3 linux/amd64 vscode-insiders (1)

This stack daD0Wg was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.3 linux/amd64 vscode-insiders (1)

dennypenta pushed a commit to dennypenta/tools that referenced this issue Dec 3, 2024
Previously, we were using the first CompiledGoFiles to disambiguate the
ID of command-line-arguments packages, but in the presence of cgo
preprocessing there can actually be multiple CompiledGoFiles, leading
to the bug report of golang/go#64557. Fix this by using GoFiles instead.

Fixes golang/go#64557

Change-Id: I3eff976d07da32db1f26ced69228af41a388d9a1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627776
Reviewed-by: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Robert Findley <[email protected]>
@adonovan
Copy link
Member Author

This stack ZWkRNQ was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 linux/amd64 vscode (1)

This stack DESvAg was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 linux/amd64 vscode (1)

This stack IGBQ2g was reported by telemetry:

golang.org/x/tools/[email protected] go1.24rc1 darwin/arm64 sublimetext (5)

This stack cgRtZA was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 linux/amd64 vscode (1)

This stack no1QsA was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 darwin/arm64 vscode (1)

This stack nSD9CA was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 linux/amd64 vscode (1)

This stack gkuQUg was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 darwin/arm64 vscode (4)

This stack 05l8Ag was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 linux/amd64 vscode (1)

This stack NOX_YQ was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 darwin/arm64 vscode (1)

This stack ThIiZA was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 linux/amd64 vscode (1)

This stack dm1LXg was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 linux/amd64 vscode (1)

This stack 4jr9sA was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 darwin/arm64 vscode (4)

This stack fGHMBg was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 darwin/arm64 vscode (1)

This stack Xb0U6w was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 darwin/arm64 vscode (1)

This stack 138-Ow was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.0 linux/amd64 vscode (1)

@adonovan
Copy link
Member Author

adonovan commented Dec 27, 2024

Reopening since this has been observed in gopls/v0.17.1. (We should automate that; #71045.)

@findleyr
Copy link
Member

Thanks. Back to the drawing board, I suppose.

@findleyr findleyr modified the milestones: gopls/v0.17.0, gopls/v0.18.0 Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

6 participants