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: slice OOB panic in fixAST on array type #70745

Open
adonovan opened this issue Dec 9, 2024 · 2 comments
Open

x/tools/gopls: slice OOB panic in fixAST on array type #70745

adonovan opened this issue Dec 9, 2024 · 2 comments
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 9, 2024

#!stacks
"goPanicSliceAcap" && "parsego.fixArrayType:+18"

Issue created by stacks.

Looks like the indices that were sliced were not what was checked with safetoken:

func fixArrayType(bad *ast.BadExpr, parent ast.Node, tok *token.File, src []byte) bool {
...
	// Avoid doing tok.Offset(to) since that panics if badExpr ends at EOF.
	// It also panics if the position is not in the range of the file, and
	// badExprs may not necessarily have good positions, so check first.
	fromOffset, toOffset, err := safetoken.Offsets(tok, from, to-1)
	if err != nil {
		return false
	}
	exprBytes = append(exprBytes, src[fromOffset:toOffset+1]...) // <------ goPanicSliceAcap

This stack N2S9sg was reported by telemetry:

golang.org/x/tools/gopls@v0.16.1 go1.23.0 darwin/arm64 other (1)

Dups: P6TRhg

@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 9, 2024
@gopherbot gopherbot added this to the Unreleased milestone Dec 9, 2024
@adonovan adonovan modified the milestones: Unreleased, gopls/v0.18.0 Dec 9, 2024
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

3 participants