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: Parse: crash in fixInitStmt #72026

Closed
adonovan opened this issue Feb 28, 2025 · 4 comments
Closed

x/tools/gopls: Parse: crash in fixInitStmt #72026

adonovan opened this issue Feb 28, 2025 · 4 comments
Assignees
Labels
BugReport Issues describing a possible bug in the Go implementation. 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 Feb 28, 2025

#!stacks
"goPanicSliceAcap" && "fixInitStmt:+10"

Issue created by stacks.

This is not how to use safetoken:

	// Try to extract a statement from the BadExpr.
	start, end, err := safetoken.Offsets(tok, bad.Pos(), bad.End()-1)
	if err != nil {
		return false
	}
	stmtBytes := src[start : end+1]
	stmt, err := parseStmt(tok, bad.Pos(), stmtBytes)
	if err != nil {
		return false
	}

This stack LKUsng was reported by telemetry:

golang.org/x/tools/[email protected] go1.24.0 linux/amd64 vscode (2)

Dups: Dyo-dQ

@adonovan adonovan added gopls Issues related to the Go language server, gopls. gopls/telemetry-wins 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. labels Feb 28, 2025
@gopherbot gopherbot added this to the Unreleased milestone Feb 28, 2025
@adonovan adonovan self-assigned this Feb 28, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/653596 mentions this issue: gopls/internal/cache/parsego: fix OOB crash in fixInitStmt

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Feb 28, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/654336 mentions this issue: gopls/internal/cache: reproduce and fix crash on if cond overflow

gopherbot pushed a commit to golang/tools that referenced this issue Mar 4, 2025
Through reverse engineering, I was able to reproduce the overflow of
golang/go#72026, and verify the fix of CL 653596.

Along the way, I incidentally reproduced golang/go#66766, which I think
we can safely ignore now that we understand it.

Updates golang/go#72026
Fixes golang/go#66766

Change-Id: I2131d771c13688c1ad47f6bc6285e524fb4c04a1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/654336
Reviewed-by: Alan Donovan <[email protected]>
Auto-Submit: Robert Findley <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. 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