x/tools/gopls: OOB index crash in completion.expectedReturnStmtType
Closed this issue · 5 comments
adonovan commented
#!stacks
"runtime.goPanicIndex" && "go/types.(*Tuple).At" && "completion.expectedReturnStmtType"
Issue created by stacks.
// expectedReturnStmtType returns the expected type of a return statement.
// Returns nil if enclosingSig is nil.
func expectedReturnStmtType(enclosingSig *types.Signature, node *ast.ReturnStmt, pos token.Pos) types.Type {
if enclosingSig != nil {
if resultIdx := exprAtPos(pos, node.Results); resultIdx < len(node.Results) {
return enclosingSig.Results().At(resultIdx).Type() // <--- At panics
}
}
return nil
}This stack 69yMYw was reported by telemetry:
crash/crashruntime.gopanic:+69runtime.goPanicIndex:+2go/types.(*Tuple).At:=34golang.org/x/tools/gopls/internal/golang/completion.expectedReturnStmtType:+3golang.org/x/tools/gopls/internal/golang/completion.expectedCandidate:+37golang.org/x/tools/gopls/internal/golang/completion.Completion:+150golang.org/x/tools/gopls/internal/server.(*server).Completion:+19golang.org/x/tools/gopls/internal/protocol.serverDispatch:+193golang.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.3 go1.23.2 linux/amd64 other,vscode (5)
gabyhelp commented
Related Issues
- x/tools/gopls: nil Signature (?) deref in Completion #70634
- x/tools/gopls: analysisinternal.ZeroValue crash on (presumably) unsafe.Pointer #70585 (closed)
- x/tools/gopls: automated issue report (crash) - unhandled basic type #40956 (closed)
- x/tools/gopls: Hover: nil deref in parseDocLink #70635
- x/tools/gopls: Hover: panic in lookupObjectByName #69616
- x/tools/gopls: crash in Hover (telemetry) #69362
- x/tools/gopls: crash in packageReferences (reported by telemetry) #66250 (closed)
- x/tools/gopls: out-of-bounds index in "stub methods" code action #64087 (closed)
- x/tools/gopls: "slice bounds out of range" crash in ExtractToNewFile #70553
- x/tools/gopls: OOB index in stubmethods.fromValueSpec (reported by telemetry) #64545 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
findleyr commented
This is indeed a logic bug, as described in #70634 (comment).
gopherbot commented
Change https://go.dev/cl/632936 mentions this issue: gopls/internal/golang/completion: fix crash with extra results
gopherbot commented
Change https://go.dev/cl/633706 mentions this issue: gopls/internal/golang/completion: fix crash with extra results