Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: OOB index crash in completion.expectedReturnStmtType #70636

Closed
adonovan opened this issue Dec 2, 2024 · 5 comments
Closed

x/tools/gopls: OOB index crash in completion.expectedReturnStmtType #70636

adonovan opened this issue Dec 2, 2024 · 5 comments
Assignees
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Dec 2, 2024

#!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:

golang.org/x/tools/[email protected] go1.23.2 linux/amd64 other,vscode (5)
@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. gopls/telemetry-wins labels Dec 2, 2024
@adonovan
Copy link
Member Author

adonovan commented Dec 2, 2024

Closely related to #70634.

@findleyr
Copy link
Member

findleyr commented Dec 2, 2024

This is indeed a logic bug, as described in #70634 (comment).

@findleyr findleyr modified the milestones: Unreleased, gopls/v0.17.0 Dec 2, 2024
@findleyr findleyr self-assigned this Dec 2, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/632936 mentions this issue: gopls/internal/golang/completion: fix crash with extra results

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/633706 mentions this issue: gopls/internal/golang/completion: fix crash with extra results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants