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

go/parser: StructType.End() can overflow the File #48300

Open
findleyr opened this issue Sep 9, 2021 · 1 comment
Open

go/parser: StructType.End() can overflow the File #48300

findleyr opened this issue Sep 9, 2021 · 1 comment
Labels
gopls/parsing Issues related to parsing / poor parser recovery. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Sep 9, 2021

As encountered in #48249, StructType.End() can overflow the file (such that File.Offset panics).

This is due to the error recovery here:
https://cs.opensource.google/go/go/+/master:src/go/parser/parser.go;l=675;drc=0406d3a8e5301bd5fd697018e6e8fbb9c75eeb42

Which will set the StructType.Fields.Closing to the end of the file, and then StructType.Fields.End overflows:
https://cs.opensource.google/go/go/+/master:src/go/ast/ast.go;l=252;drc=master

This is a low priority (the logic that gopls was using should have been more robust), but I feel like it should be an invariant of nodes that if Pos() or End() is not token.NoPos, they have a valid offset.

Are there counter-arguments or contradicting precedent?

CC @griesemer @stamblerre

@findleyr findleyr added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 9, 2021
@findleyr findleyr added this to the Backlog milestone Sep 9, 2021
@adonovan
Copy link
Member

adonovan commented Mar 2, 2023

Related: #57490

@adonovan adonovan added the gopls/parsing Issues related to parsing / poor parser recovery. label Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/parsing Issues related to parsing / poor parser recovery. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants