x/tools/gopls: stubmethods: nil deref of FuncType.Results in fromReturnStmt
Closed this issue · 3 comments
adonovan commented
#!stacks
"runtime.sigpanic" && ("fromReturnStmt:+26" || "fromReturnStmt:+27")
Issue created by stacks.
Oops, the Results field is optional, and in any case NumFields is the correct measure:
if len(funcType.Results.List) != len(ret.Results) {
return nil, fmt.Errorf("%d-operand return statement in %d-result function",
len(ret.Results),
len(funcType.Results.List))
}This stack ArQqdg was reported by telemetry:
crash/crashruntime.gopanic:+69runtime.panicmem:=262runtime.sigpanic:+19golang.org/x/tools/gopls/internal/golang/stubmethods.fromReturnStmt:+26golang.org/x/tools/gopls/internal/golang/stubmethods.GetIfaceStubInfo:+10golang.org/x/tools/gopls/internal/golang.quickFix:+44golang.org/x/tools/gopls/internal/golang.CodeActions:+65golang.org/x/tools/gopls/internal/server.(*server).CodeAction:+154golang.org/x/tools/gopls/internal/protocol.serverDispatch:+160golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3runtime.goexit:+0
golang.org/x/tools/gopls@v0.17.0-pre.2 go1.23.3 darwin/arm64 other (5)
gabyhelp commented
Related Issues
- x/tools/gopls: nil Signature (?) deref in Completion #70634 (closed)
- x/tools/gopls: OOB index crash in completion.expectedReturnStmtType #70636 (closed)
- x/tools/gopls: bug report in GetIfaceStubInfo #70666
- x/tools/gopls: out-of-bounds index in "stub methods" code action #64087 (closed)
- x/tools/gopls: completion: failed type assertion in inferExpectedTypeArg #70889 (closed)
- x/tools/gopls: Hover: nil deref in parseDocLink #70635 (closed)
- x/tools/gopls: Completion: "ZeroString for unexpected type" panic #70744 (closed)
- x/tools/gopls: OOB index in stubmethods.fromValueSpec (reported by telemetry) #64545 (closed)
- x/tools/gopls: crash in Hover (telemetry) #69362
- x/tools/gopls: analysisinternal.ZeroValue crash on (presumably) unsafe.Pointer #70585 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
adonovan commented
I think this was fixed in passing by https://go.dev/cl/623156 which changed it to:
rets := sig.Results()
// The return operands and function results must match.
// (Spread returns were rejected earlier.)
if rets.Len() != len(ret.Results) {
return nil, fmt.Errorf("%d-operand return statement in %d-result function",
len(ret.Results),
rets.Len())
}adonovan commented
Presumed fixed, closing.