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

Compiler doesn't terminate on file with syntax errors #72557

Closed
tamasvajk opened this issue Mar 15, 2024 · 4 comments · Fixed by #72565
Closed

Compiler doesn't terminate on file with syntax errors #72557

tamasvajk opened this issue Mar 15, 2024 · 4 comments · Fixed by #72565
Assignees
Milestone

Comments

@tamasvajk
Copy link
Contributor

tamasvajk commented Mar 15, 2024

Version Used:
C# Compiler version 4.8.0-7.23572.1 (7b75981)

Steps to Reproduce:

  1. Get this file from microsoft/fhir-codegen.
  2. Run dotnet /usr/local/share/dotnet/sdk/8.0.101/Roslyn/bincore/csc.dll generated/CSharpFirely2_R5/Generated/Bundle.cs

Another option is copying the content of that file into https://sharplab.io/.

Expected Behavior:
The compiler should terminate in reasonable time.

Actual Behavior:
The compiler doesn't terminate in reasonable time.

Additional Note:
C# Compiler version 3.9.0-6.21124.20 (db94f4c) can parse the file, and it reports the syntax errors.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 15, 2024
@cston
Copy link
Member

cston commented Mar 15, 2024

@CyrusNajmabadi, it looks like parsing ends up in LanguageParser.ParseCollectionExpression() and unable to make progress.

@CyrusNajmabadi
Copy link
Member

Relates to this error construct:

      [EnumLiteral("archives", "http://hl7.org/fhir/CodeSystem/iana-link-relations"), Description("Refers to a collection of records, documents, or other
      materials of historical interest.")]
      Archives,

Note the wrapping over multiple lines.

@CyrusNajmabadi
Copy link
Member

Ick. this is challenging/problematic. So the string is unterminated on the first line. So we terminate it (with an error saying it is missing). But then we get to the next line and we are just in extreme error mode. We see "materials", "of", "historical" "interest" all as continued arguments. We then hit the quote and that stats ")] another argument to the attribute. And, at that point, all the remaining enum members just appear to be more and more arguments. And, of course, as arguments, we think we might be seeing collection-exprs when we run into attributes on the enum members. THis starts a cascading of speculative parsing, which explodes given how many elements there are. Will have to noodle on what we can do here.

@CyrusNajmabadi
Copy link
Member

Note: it's not an infinite loop. More just really expensive with backtracking and retrying things.

@jaredpar jaredpar added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 19, 2024
@jaredpar jaredpar added this to the 17.10 milestone Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants