You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
go/parser: StructType.End() can underflow the File #66683
A struct type with a missing close brace has an StructType.End pos of zero. That means the enclosing nodes such as ReturnStmt may also have a computed End that is zero, or perhaps slightly larger:
I believe this is the root cause of at least some of the many gopls crashes recorded in #64547.
Ultimately this is a problem of parser error recovery. We need to establish the invariants that:
all tree nodes have valid Pos/End positions; and
all tree nodes have nested Pos/End subranges (with a possible exception for the func keyword in FuncDecl/FuncType).
Activity
[-]go/parser: StructType.End() can overflow the File[/-][+]go/parser: StructType.End() can underflow the File[/+]gopherbot commentedon Apr 4, 2024
Change https://go.dev/cl/576655 mentions this issue:
gopls/internal/cache: analysis: repair start/end and refine bug reportgopls/internal/cache: analysis: repair start/end and refine bug report
findleyr commentedon Apr 8, 2024
Let's try to fix this for Go 1.23. Adding to the milestone.
gopherbot commentedon Apr 9, 2024
Change https://go.dev/cl/577595 mentions this issue:
[gopls-release-branch.0.15] gopls/internal/cache: analysis: repair start/end and refine bug report[gopls-release-branch.0.15] gopls/internal/cache: analysis: repair st…
adonovan commentedon Apr 11, 2024
@findleyr suggests that a fuzzer connected to an invariant checker would be a good source of regression test cases.
findleyr commentedon Apr 12, 2024
Shall we expand this issue to introducing and enforcing our stated invariant?
adonovan commentedon Apr 12, 2024
Perhaps we need an umbrella issue. See also #66790 (comment), which is the beginning of a theory of pos/end in ill-formed trees.
gopherbot commentedon Nov 21, 2024
Change https://go.dev/cl/630675 mentions this issue:
gopls/internal/crash: don't crash in xrefs on out of bound nodesgopls/internal/crash: don't crash in xrefs on out of bound nodes
gopherbot commentedon Apr 25, 2025
Change https://go.dev/cl/668238 mentions this issue:
go/ast: enforce FileStart <= Node.Pos <= Node.End <= FileEndgopherbot commentedon Apr 28, 2025
Change https://go.dev/cl/668677 mentions this issue:
x/tools: prepare for go1.25 parser changesgopherbot commentedon May 12, 2025
Change https://go.dev/cl/672055 mentions this issue:
x/tools: various cleanups related to planned parser changesx/tools: various cleanups related to planned parser changes