golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.86k stars 17.65k forks source link

x/tools/gopls: bug: load.go:185: go/packages returned unexpected package "golang.org/x/tools/go/callgraph/cha/testdata/iface.go.~master~" for standalone file #69331

Closed adonovan closed 1 week ago

adonovan commented 1 month ago

I noticed that gopls had a bug report in its filecache, and typed gopls bug, perhaps for the first time ever:

Gopls detected 2 internal errors, 1 distinct:

-- 2024-09-06 13:14:49.814906 -0400 EDT --

/Users/adonovan/w/xtools/gopls/internal/cache/load.go:185: internal error: go/packages returned unexpected package "golang.org/x/tools/go/callgraph/cha/testdata/iface.go.~master~" for standalone file (1/2)

goroutine 478469 [running]: runtime/debug.Stack() /Users/adonovan/w/goroot/src/runtime/debug/stack.go:26 +0x64 golang.org/x/tools/gopls/internal/util/bug.report({0x1400c18f9e0, 0x8c}) /Users/adonovan/w/xtools/gopls/internal/util/bug/bug.go:91 +0xd4 golang.org/x/tools/gopls/internal/util/bug.Errorf({0x10553b2a6?, 0x3e?}, {0x14019756730?, 0x1?, 0x140131124b0?}) /Users/adonovan/w/xtools/gopls/internal/util/bug/bug.go:61 +0x3c golang.org/x/tools/gopls/internal/cache.(Snapshot).load(0x1400759d9e0, {0x1059cb588, 0x1400e7d24b0}, 0x0, {0x1400025d530, 0x1, 0x0?}) /Users/adonovan/w/xtools/gopls/internal/cache/load.go:185 +0x1a74 golang.org/x/tools/gopls/internal/cache.(Snapshot).MetadataForFile(0x1400759d9e0, {0x1059cb588, 0x1400e7d24b0}, {0x140155c9260, 0x4b}) /Users/adonovan/w/xtools/gopls/internal/cache/snapshot.go:719 +0x2a8 golang.org/x/tools/gopls/internal/golang.selectPackageForFile({0x1059cb588, 0x1400e7d24b0}, 0x1400759d9e0, {0x140155c9260, 0x4b}, 0x1059bcb08) /Users/adonovan/w/xtools/gopls/internal/golang/snapshot.go:70 +0x4c golang.org/x/tools/gopls/internal/golang.NarrowestPackageForFile({0x1059cb588?, 0x1400e7d24b0?}, 0x1054dfa78?, {0x140155c9260?, 0x0?}) /Users/adonovan/w/xtools/gopls/internal/golang/snapshot.go:48 +0x30 golang.org/x/tools/gopls/internal/golang.InlayHint({0x1059cb588?, 0x1400e7d2360?}, 0x1400759d9e0, {0x1059ce340, 0x140197a4d20}, {{0x5809520?, 0x1?}, {0xe7d2270?, 0x140?}}) /Users/adonovan/w/xtools/gopls/internal/golang/inlay_hint.go:30 +0xb0 golang.org/x/tools/gopls/internal/server.(server).InlayHint(0x1400030e480, {0x1059cb5c0, 0x140108e2c80}, 0x1400e7d2270) /Users/adonovan/w/xtools/gopls/internal/server/inlay_hint.go:32 +0x278 golang.org/x/tools/gopls/internal/protocol.serverDispatch({0x1059cb5c0, 0x140108e2c80}, {0x1059e68a0, 0x1400030e480}, 0x1400e7d2240, {0x1059cb780, 0x1401f3e3f40}) /Users/adonovan/w/xtools/gopls/internal/protocol/tsserver.go:525 +0x19a0 golang.org/x/tools/gopls/internal/lsprpc.(streamServer).ServeStream.ServerHandler.func3({0x1059cb5c0, 0x140108e2c80}, 0x1400e7d2240, {0x1059cb780, 0x1401f3e3f40}) /Users/adonovan/w/xtools/gopls/internal/protocol/protocol.go:160 +0x74 golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4({0x1059cb5c0, 0x140108e2c80}, 0x1400e7d2240, {0x1059cb780, 0x1401f3e3f40}) /Users/adonovan/w/xtools/gopls/internal/lsprpc/lsprpc.go:509 +0x6b8 golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1({0x1059cb5c0, 0x140108e2c80}, 0x14013422810, {0x1059cb780, 0x1401f3e3f40}) /Users/adonovan/w/xtools/internal/jsonrpc2/handler.go:35 +0xc0 golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2() /Users/adonovan/w/xtools/internal/jsonrpc2/handler.go:103 +0x90 created by golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2 in goroutine 105 /Users/adonovan/w/xtools/internal/jsonrpc2/handler.go:100 +0x19c

-- 2024-09-06 14:03:50.182545 -0400 EDT -- /Users/adonovan/w/xtools/gopls/internal/cache/load.go:185: internal error: go/packages returned unexpected package "golang.org/x/tools/go/callgraph/cha/testdata/func.go.~master~" for standalone file (2/2)

goroutine 42303 [running]: runtime/debug.Stack() /Users/adonovan/w/goroot/src/runtime/debug/stack.go:26 +0x64 golang.org/x/tools/gopls/internal/util/bug.report({0x14010174510, 0x8b}) /Users/adonovan/w/xtools/gopls/internal/util/bug/bug.go:91 +0xd4 golang.org/x/tools/gopls/internal/util/bug.Errorf({0x10557f2a6?, 0x3d?}, {0x14015c3dbc0?, 0x1?, 0x1400af80b40?}) /Users/adonovan/w/xtools/gopls/internal/util/bug/bug.go:61 +0x3c golang.org/x/tools/gopls/internal/cache.(Snapshot).load(0x1401581bd40, {0x105a0f588, 0x140167c50e0}, 0x0, {0x140078d9530, 0x1, 0x0?}) /Users/adonovan/w/xtools/gopls/internal/cache/load.go:185 +0x1a74 golang.org/x/tools/gopls/internal/cache.(Snapshot).MetadataForFile(0x1401581bd40, {0x105a0f588, 0x140167c50e0}, {0x14012916b40, 0x4a}) /Users/adonovan/w/xtools/gopls/internal/cache/snapshot.go:719 +0x2a8 golang.org/x/tools/gopls/internal/golang.selectPackageForFile({0x105a0f588, 0x140167c50e0}, 0x1401581bd40, {0x14012916b40, 0x4a}, 0x105a00b08) /Users/adonovan/w/xtools/gopls/internal/golang/snapshot.go:70 +0x4c golang.org/x/tools/gopls/internal/golang.NarrowestPackageForFile({0x105a0f588?, 0x140167c50e0?}, 0x105523a78?, {0x14012916b40?, 0x0?}) /Users/adonovan/w/xtools/gopls/internal/golang/snapshot.go:48 +0x30 golang.org/x/tools/gopls/internal/golang.InlayHint({0x105a0f588?, 0x140167c4f90?}, 0x1401581bd40, {0x105a12340, 0x14015d60ae0}, {{0x584d520?, 0x1?}, {0x167c4ea0?, 0x140?}}) /Users/adonovan/w/xtools/gopls/internal/golang/inlay_hint.go:30 +0xb0 golang.org/x/tools/gopls/internal/server.(server).InlayHint(0x14000032480, {0x105a0f5c0, 0x140159419f0}, 0x140167c4ea0) /Users/adonovan/w/xtools/gopls/internal/server/inlay_hint.go:32 +0x278 golang.org/x/tools/gopls/internal/protocol.serverDispatch({0x105a0f5c0, 0x140159419f0}, {0x105a2a8a0, 0x14000032480}, 0x140167c4e70, {0x105a0f780, 0x1401597e5c0}) /Users/adonovan/w/xtools/gopls/internal/protocol/tsserver.go:525 +0x19a0 golang.org/x/tools/gopls/internal/lsprpc.(streamServer).ServeStream.ServerHandler.func3({0x105a0f5c0, 0x140159419f0}, 0x140167c4e70, {0x105a0f780, 0x1401597e5c0}) /Users/adonovan/w/xtools/gopls/internal/protocol/protocol.go:160 +0x74 golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4({0x105a0f5c0, 0x140159419f0}, 0x140167c4e70, {0x105a0f780, 0x1401597e5c0}) /Users/adonovan/w/xtools/gopls/internal/lsprpc/lsprpc.go:509 +0x6b8 golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1({0x105a0f5c0, 0x140159419f0}, 0x14015978918, {0x105a0f780, 0x1401597e5c0}) /Users/adonovan/w/xtools/internal/jsonrpc2/handler.go:35 +0xc0 golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2() /Users/adonovan/w/xtools/internal/jsonrpc2/handler.go:103 +0x90 created by golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2 in goroutine 94 /Users/adonovan/w/xtools/internal/jsonrpc2/handler.go:100 +0x19c

Build info

golang.org/x/tools/gopls (devel)
    golang.org/x/tools/gopls@(devel)
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/mod@v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
    golang.org/x/sync@v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
    golang.org/x/telemetry@v0.0.0-20240712210958-268b4a8ec2d7 h1:nU8/tAV/21mkPrCjACUeSibjhynTovgRMXc32+Y1Aec=
    golang.org/x/text@v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
    golang.org/x/tools@(devel)
    golang.org/x/vuln@v1.0.4 h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
    honnef.co/go/tools@v0.4.7 h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
    mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: devel go1.24-760b722c34 Fri Aug 9 14:54:31 2024 +0000
gabyhelp commented 1 month ago

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

findleyr commented 1 week ago

This should also have been fixed by https://go.dev/cl/621859.