#!stacks
"sigpanic" && "types.(*Selection).Index" && "golang.hover:+188"
Issue created by stacks.
// When hovering over a reference to a promoted struct field,
// show the implicitly selected intervening fields.
cur, ok := pgf.Cursor.FindByPos(pos, pos)
if !ok {
return protocol.Range{}, nil, fmt.Errorf("Invalid hover position, failed to get cursor")
}
if obj, ok := obj.(*types.Var); ok && obj.IsField() {
if selExpr, ok := cur.Parent().Node().(*ast.SelectorExpr); ok {
sel := pkg.TypesInfo().Selections[selExpr]
if len(sel.Index()) > 1 { <----- panics is sel is zero
@madelinekalil
This stack j9Y3kA
was reported by telemetry:
crash/crash
runtime.gopanic:+69,+0x167
runtime.panicmem:=262,+0x197
runtime.sigpanic:+9,+0x167
go/types.(*Selection).Index:=137,+0xf4e
golang.org/x/tools/gopls/internal/golang.hover:+188,+0xf53
golang.org/x/tools/gopls/internal/golang.Hover:+4,+0xbe
golang.org/x/tools/gopls/internal/server.(*server).Hover:+30,+0x3aa
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+335,+0xe99
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func4:+5,+0x84
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func5:+52,+0x908
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2,+0xc5
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3,+0x95
runtime.goexit:+0,+0x0
golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 windows/amd64 vscode (1)
Dups: nagHbw
Comment From: adonovan
Let's cherrypick a fix for this into rc3.
Comment From: adonovan
This stack nagHbw
was reported by telemetry:
crash/crash
runtime.gopanic:+69,+0x153
runtime.panicmem:=262,+0x2ff
runtime.sigpanic:+19,+0x2cc
go/types.(*Selection).Index:=137,+0xc60
golang.org/x/tools/gopls/internal/golang.hover:+188,+0xc64
golang.org/x/tools/gopls/internal/golang.Hover:+4,+0x8b
golang.org/x/tools/gopls/internal/server.(*server).Hover:+30,+0x29b
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+335,+0xc57
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func4:+5,+0x73
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func5:+52,+0x68f
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2,+0xbf
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3,+0x8f
runtime.goexit:+0,+0x3
golang.org/x/tools/gopls@v0.19.0-pre.1 go1.24.3 darwin/arm64 other (1)
Comment From: gopherbot
Change https://go.dev/cl/680257 mentions this issue: gopls/internal/golang: add missing ,ok check
Comment From: gabyhelp
Related Issues
- x/tools/gopls: Hover: nil deref in parseDocLink #70635 (closed)
- x/tools/gopls: Hover: nil deref in golang.StdSymbolOf #70969 (closed)
- x/tools/gopls: Hover: invalid nil entry in types.Defs map #69362 (closed)
- x/tools/gopls: Hover: nil deref in typeDeclContent #74056
- x/tools/gopls: panic in hover #52211 (closed)
- x/tools/gopls: nil deref in x/telemetry/internal/counter.(*Counter).add #73890
- x/tools/gopls: "type name %q without type spec" bug in Hover (via telemetry) #64241
- x/tools/gopls: "type name %q without type spec" bug in Hover(reported by telemetry) #66314 (closed)
- x/tools/gopls: panic in mod.hoverOnModuleStatement #59077 (closed)
- x/tools/gopls: crash in work.Hover #60821 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)