Open adonovan opened 10 months ago
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'"
}
}
Change https://go.dev/cl/560465 mentions this issue: gopls/internal/cache: allow command-line-package >1 CompileGoFiles
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/gopls@v0.14.2 devel windows/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
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/gopls@v0.15.0-pre.2 go1.22rc1 linux/amd64 vscodium (2)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
Reopening due to new field reports at v0.15.
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/gopls@v0.15.1 go1.22.0 darwin/arm64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
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/gopls@v0.15.2 go1.22.1 linux/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
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/gopls@v0.15.2 go1.21.8 darwin/arm64 other,vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
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/gopls@v0.15.2 go1.22.1 linux/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
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/gopls@v0.15.2 go1.22.1 linux/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
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/gopls@v0.15.2 go1.22.1 linux/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
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/gopls@v0.15.3 go1.22.2 linux/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
27 reported crashes this week... I really need to make some progress on this one.
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"
]
}
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/gopls@v0.15.3 go1.22.0 darwin/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
This stack DdP2cQ
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.InlayHint:+4
golang.org/x/tools/gopls/internal/server.(*server).InlayHint:+14
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+357
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/gopls@v0.15.3 go1.22.2 linux/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
The go command explicitly checks to see if a ".go" pattern is not a directory when making a command-line-arguments package. See https://cs.opensource.google/go/go/+/master:src/cmd/go/internal/load/pkg.go;l=2791;drc=94aeedc33a4434f0d410be7c42e0bbcdaedd790f . Otherwise the pattern is treated as matching a package. The linked code also links to issue #34653, where a bug was reported (and fixed) about ".go" packages not being supported.
This stack 5Um4Rg
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:+19
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+220
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:+87
golang.org/x/tools/gopls/internal/server.(*server).CodeAction:+106
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/gopls@v0.16.1 go1.22.3 windows/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
This stack yWpCHQ
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:+19
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+220
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:+25
golang.org/x/tools/gopls/internal/server.(*server).diagnoseChangedViews.func1:+3
runtime.goexit:+0
golang.org/x/tools/gopls@v0.16.1 go1.22.4 windows/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
This stack ziMhMQ
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:+19
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+220
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/gopls@v0.16.1 go1.22.4 windows/amd64 sublimetext (3)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
This stack 49eF6g
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:+19
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+220
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:+55
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/gopls@v0.16.1 go1.23.0 linux/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
This stack rAKLNA
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:+19
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+220
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.InlayHint:+4
golang.org/x/tools/gopls/internal/server.(*server).InlayHint:+14
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+357
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/gopls@v0.16.1 go1.22.5 linux/amd64 neovim (2)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
This stack rAKLNA
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:+19
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+220
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.InlayHint:+4
golang.org/x/tools/gopls/internal/server.(*server).InlayHint:+14
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+357
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/gopls@v0.16.1 go1.22.5 linux/amd64 neovim (2)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
This stack bm9HIg
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.(*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/gopls@v0.15.3 go1.22.2 darwin/arm64 other (2)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
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.
@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"
}
}
Yay! Repro at https://github.com/golang/go/issues/64557#issuecomment-2364675959
This stacks
EVz2Fg
,ELG5Yw
,ND0D7A
were reported by telemetry:Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
Duplicates:
This stack
dDf6yw
was reported by telemetry:This stack
Es6nFQ
was reported by telemetry:Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
This stack
OBhdqw
was reported by telemetry: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