-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone 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.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/telemetry-wins
Milestone
Description
#!stacks
"sigpanic" && "golang.isBuiltin" && "golang.ObjectLocation" && "mcp.(*handler).symbolReferencesHandler:+32"
Issue created by stacks.
resolveSymbol may return (nil, nil) leading to a panic
func resolveSymbol(path []string, pkg *cache.Package, pgf *parsego.File) (types.Object, error) {
...
switch len(path) {
case 1:
_, target := fileScope.LookupParent(path[0], token.NoPos)
return target, nil <------- here
case 2:
switch _, obj := fileScope.LookupParent(path[0], token.NoPos); obj := obj.(type) {
...
default:
target, _, _ := types.LookupFieldOrMethod(obj.Type(), true, pkg.Types(), path[1])
return target, nil <---------- here
}
target, err := resolveSymbol(path, pkg, pgf)
if err != nil {
return nil, err
}
loc, err := golang.ObjectLocation(ctx, pkg.FileSet(), snapshot, target) <---- target = nil; panics in isBuiltin
This stack hZ-M9w
was reported by telemetry:
crash/crash
runtime.gopanic:+69,+0x153
runtime.panicmem:=262,+0x2ff
runtime.sigpanic:+19,+0x2cc
golang.org/x/tools/gopls/internal/golang.isBuiltin:=288,+0x34
golang.org/x/tools/gopls/internal/golang.ObjectLocation:+1,+0x1c
golang.org/x/tools/gopls/internal/mcp.(*handler).symbolReferencesHandler:+32,+0x17b
golang.org/x/tools/gopls/internal/mcp.(*handler).symbolReferencesHandler-fm:+0,+0x43
golang.org/x/tools/internal/mcp.newServerToolErr[...].func1:+14,+0x13b
golang.org/x/tools/internal/mcp.(*Server).callTool:+7,+0x1bf
golang.org/x/tools/internal/mcp.init.serverMethod[...].func53:+1,+0x43
golang.org/x/tools/internal/mcp.init.newMethodInfo[...].func55:+4,+0x4f
golang.org/x/tools/internal/mcp.defaultReceivingMethodHandler[...]:+6,+0x9f
golang.org/x/tools/internal/mcp.defaultReceivingMethodHandler[...]:+0,+0x5b
golang.org/x/tools/internal/mcp.handleReceive[...]:+12,+0x15f
golang.org/x/tools/internal/mcp.(*ServerSession).handle:+18,+0x1c7
golang.org/x/tools/internal/mcp.connect[...].func1.1:+0,+0x47
golang.org/x/tools/internal/jsonrpc2_v2.HandlerFunc.Handle:+1,+0x37
golang.org/x/tools/internal/jsonrpc2_v2.(*Connection).handleAsync:+27,+0xdf
golang.org/x/tools/gopls@v0.20.0 go1.24.5 darwin/arm64 neovim,other (1)
golang.org/x/tools/gopls@v0.20.0-pre.1 go1.24.5 darwin/arm64 other (1)
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone 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.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/telemetry-wins