Closed
Description
Another crash w2Y-6g
, H0UbWA
reported by telemetry:
golang.org/x/tools/gopls/internal/lsp/analysis/stubmethods fromReturnStmt:18
golang.org/x/tools/gopls/internal/lsp/analysis/stubmethods GetStubInfo:10
golang.org/x/tools/gopls/internal/lsp/analysis/stubmethods DiagnosticForError:6
golang.org/x/tools/gopls/internal/lsp (*Server).codeAction
golang.org/x/tools/gopls/internal/lsp (*Server).codeAction:210
golang.org/x/tools/gopls/internal/lsp (*Server).CodeAction:1
- golang.org/x/tools/gopls@v0.14.1 go1.19.1 darwin/amd64 (1)
func fromReturnStmt(fset *token.FileSet, ti *types.Info, pos token.Pos, path []ast.Node, rs *ast.ReturnStmt) (*StubInfo, error) {
returnIdx := -1
for i, r := range rs.Results {
if pos >= r.Pos() && pos <= r.End() {
returnIdx = i
}
}
if returnIdx == -1 {
return nil, fmt.Errorf("pos %d not within return statement bounds: [%d-%d]", pos, rs.Pos(), rs.End())
}
concObj, pointer := concreteType(rs.Results[returnIdx], ti)
if concObj == nil || concObj.Obj().Pkg() == nil {
return nil, nil
}
ef := enclosingFunction(path, ti)
if ef == nil {
return nil, fmt.Errorf("could not find the enclosing function of the return statement")
}
iface := ifaceType(ef.Results.List[returnIdx].Type, ti) /// <--- this line fails, presumably because the index is OOB
if iface == nil {
return nil, nil
}
...
Duplicates:
This stack R0oUQw
was reported by telemetry:
gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Errorf:2
golang.org/x/tools/gopls/internal/lsp.(*Server).codeAction.func1.1:2
runtime.gopanic:88
runtime.panicmem:?261
runtime.sigpanic:9
golang.org/x/tools/gopls/internal/lsp/analysis/stubmethods.fromReturnStmt:18
golang.org/x/tools/gopls/internal/lsp/analysis/stubmethods.GetStubInfo:10
golang.org/x/tools/gopls/internal/lsp/analysis/stubmethods.DiagnosticForError:6
golang.org/x/tools/gopls/internal/lsp.(*Server).codeAction.func1:11
golang.org/x/tools/gopls/internal/lsp.(*Server).codeAction:210
golang.org/x/tools/gopls/internal/lsp.(*Server).CodeAction:1
golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch:142
golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3:5
golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4:52
golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1:2
golang.org/x/tools/gopls@v0.14.2 go1.21.4 windows/amd64 vscode (1)
Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
Dups: NNo9gw 8eUSuQ Mw6nJQ
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
adonovan commentedon Nov 12, 2023
This program reproduces the panic. The
int("")
triggers a "cannot convert" error, which causes GetStubInfo to assume the problem is because of a mismatched return operand and result type, but in fact there is no corresponding result type.[-]gopls: out-of-bounds index in "stub methods" code action[/-][+]x/tools/gopls: out-of-bounds index in "stub methods" code action[/+]gopherbot commentedon Nov 16, 2023
Change https://go.dev/cl/543018 mentions this issue:
gopls/internal/lsp/source: stubmethods: fix out-of-bounds index
[-]x/tools/gopls: out-of-bounds index in "stub methods" code action[/-][+]x/tools/gopls: out-of-bounds index in "stub methods" code action [w2Y-6g][/+][-]x/tools/gopls: out-of-bounds index in "stub methods" code action [w2Y-6g][/-][+]x/tools/gopls: out-of-bounds index in "stub methods" code action[/+]gopherbot commentedon Dec 11, 2023
Change https://go.dev/cl/548737 mentions this issue:
gopls/internal/analysis/stubmethods: fix OOB panic in fromValueSpec
gopls/internal/analysis/stubmethods: fix OOB panic in fromValueSpec
gopls/internal/lsp/source: stubmethods: fix out-of-bounds index
adonovan commentedon Feb 27, 2024
This stack
Mw6nJQ
was reported by telemetry:Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
adonovan commentedon Feb 27, 2024
This stack
8eUSuQ
was reported by telemetry:Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.
adonovan commentedon Feb 27, 2024
This stack
NNo9gw
was reported by telemetry:Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.