-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
StackOverflowException on web project code analysis #76953
Comments
@joperezr we probably need to port dotnet/roslyn#64322 over to the runtime repo. I'll contact you today about the process around that. |
I have checked another issue related to the dotnet/roslyn#64322 fix, and the repro project there also uses ANTLR, just as we do. |
@PatrickHofman can you please attach the project? That would be helpful with validating the fix. Or at least the large file antlr produces. |
I can't put the original files here, since they are confidential. I have been digging a little deeper, and since I know this might be ANTLR related, I isolated the grammar G4 files. I narrowed it down to a grammar with a single rule, and the original list of tokens. I could delete a fair amount of tokens, until suddenly the solution did open and build. I then isolated the failing generated ANTLR code and put it in a separate project file. It seems the number of string concatenations done is the problem here. I will attach a single file that once put in a default .NET 6 Console App will make VS crash. |
hey @PatrickHofman we're creating fixes for this right now. One thing that would help is if you can add a little more info on the impact to VS. When you say it 'crashes' can you be specific on exactly the experience you are getting? Do you mean that the process completely dies and VS disappears? Or is it more that you get a message saying there was an error? Similarly, what happens if you try to compile from the command line? Thanks! |
@PatrickHofman Thanks so much for your example file. Would it be possible to have the original antlr file that generated that? i just want to get a sense for how big the grammar is that causes this. Thanks! |
@PatrickHofman @sharwell Does antlr have a mode where it doesn't emit a string as such an unbalanced binary-tree? e.g. if it can just emit it as one long string, instead of 2000 concats. (or if it can emit it with a lower number of concats). Just looking to see if there's a workaround to help you and others in the interim while this is worked on. |
@PatrickHofman as a workaround, you can disable the Json Source generator from being automatically added to your project if you are not using it by adding the following target into your .csproj: <Target Name="RemoveJsonSourceGenerator"
BeforeTargets="CoreCompile">
<ItemGroup>
<AnalyzersByFileName Include="@(Analyzer -> '%(FileName)')">
<OriginalIdentity>%(Identity)</OriginalIdentity>
</AnalyzersByFileName>
<AnalyzersToRemoveByFileName Include="System.Text.Json.SourceGeneration" />
</ItemGroup>
<ItemGroup>
<AnalyzersToRemove Include="@(AnalyzersByFileName)" Condition="'@(AnalyzersToRemoveByFileName)' == '@(AnalyzersByFileName)' and '%(Identity)' != ''" />
<Analyzer Remove="%(AnalyzersToRemove.OriginalIdentity)" />
</ItemGroup>
</Target> This is of course not the right fix, as this would not work in case you actually do use the Json Source generator, but it is a temporary workaround that people can use while we prepare a servicing fix for 6.0 |
I'm going to move this to the runtime repo as this is not an issue with roslyn (as evident with this in the callstack: |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@CyrusNajmabadi Thanks for all the effort. I can't post the original token file here, but it describes a SQL language dialect, covering most of SQL92 syntax (select, insert, update, delete), including joins, where, limit, etc. It also describes a sort of programmatic SQL (like PL/SQL, PL/pgSQL, etc). The documentation of the SQL syntax can be found here: https://documentation.invantive.com/2017R2/invantive-sql-grammar/invantive-sql-grammar-22.1.html. In my case, Visual Studio freezes (seems to analyze/generate in the background), and after 30 seconds or so, it just vanishes. No error shown. I am not sure if ANTLR has such an option, I can't find one. @sharwell might be of help here. @joperezr I am not sure if we are using the JsonSourceGenerator, but putting the remove target in our project file does fix the issue for now. Thanks a lot! |
As a side note, this also breaks MSBuild yielding a StackOverflow on build, not just Visual Studio. |
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsVersion Used: Steps to Reproduce:
Expected Behavior: Actual Behavior: When inspecting a Windows dump file created on crash, it shows this call stack ending up in a stack overflow (on both versions mentioned, the call stack is the same):
|
@CyrusNajmabadi is there still a fix "in-pr", or did it turn out to be a completely different problem than what you originally assumed? |
@dakersnar there is the same fix, pushed to 3 locations (6.0, 7.0, 8.0):
Not sure what you mean by this. Can you clarify? :) |
Version Used:
17.3.6
17.4.0 Preview 3
Steps to Reproduce:
Expected Behavior:
Visual Studio to open and fully load, not crash.
Actual Behavior:
Visual Studio crashes after the solution is opened with no error message shown.
When inspecting a Windows dump file created on crash, it shows this call stack ending up in a stack overflow (on both versions mentioned, the call stack is the same):
The text was updated successfully, but these errors were encountered: