-
Notifications
You must be signed in to change notification settings - Fork 229
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
CfgAllPathValidator AreAllSuccessorsValid Stack Overflow on Windows and error MSB6006 in Linux Codespaces #8977
Comments
Hello @giuliohome I tried to reproduce the issue but I wasn't able to do so. I created a .Net 8 console app and added the https://github.com/dotnet/Open-XML-SDK/blob/main/test/DocumentFormat.OpenXml.Tests/ConformanceTest/WorkbookPr/GeneratedDocument.cs file and Are you sure about the document in question? Can you provide a sample project with the error? |
Hi, @martin-strecker-sonarsource, I understand that you are unable to reproduce the error using only that file, exactly as it appears in the original version. I acknowledge that. Unfortunately, I cannot currently provide the full code (although I do have a deterministic reproduction of the issue). I'm not sure if I or someone else will be able to provide it later. While you keep this on hold (or close it), here are a few hints: The .cs file is generated from an .xlsx file, so consider that the bug may simply occur with a "different" but fundamentally similar template (more rows, different formatting). The issue lies in the fact that 1) the memory consumption while analyzing it (even when it does not throw an exception) could be quite excessive and 2) producing code smells from C# code generated from an .xlsx file by a Microsoft tool could be misleading when referring to the applicative project that simply uses a widely accepted library like the OpenXML SDK. |
Hi, If the file causing the problems is auto-generated and you can control the code generation, it is recommended that such code be excluded from the analysis. To stop our analyzer from looking into such files, you can do either of these
If you can not influence the code generation, you can use any of these options for file exclusions: It would still be helpful for us if you could help us create a reproducer. I suspect your generated file is huge but has a lot of repeating patterns. Can you give us some hints about these patterns, e.g., one giant method with simple statements, many small methods, or a huge method with a massive switch statement? |
Okay, thank you! That's incredible. On Windows, adding I'm not sure if it optimizes memory usage on the Linux container as well, but I'll open a different issue if that's the problem. Thanks! |
Hi, I'm glad that helped you. We take it very seriously when our analyzer breaks the build. Can you give us some more information about the generated code, so we can try reproducing the issue even though it is resolved for you? See also the second paragraph of #8977 (comment) |
Thanks, I'll send you a repro, but I need to minimize it and delete any private info beforehand.
Yes, exactly. For example, P.S. (Please note that the situation on Linux may differ, and if that's the case, it would be more important from my perspective.) |
I'm not going to open a different issue on Linux, but just look at what happens when you build it in Codespaces. Codespaces
And even if you run it and time it there:
Enters sonar-dotnet analyzer
Adding |
Thank you, @giuliohome, for the detailed re-producer and instructions. I opened PR #8984 with the code based on https://github.com/giuliohome-org/sonar-dotnet-issues-8977. The unit test is falling with the StackOverflow, so we can investigate and see what we can do about it. We will also take the performance problem into account while looking at it. |
Thanks! Much appreciated @martin-strecker-sonarsource |
@martin-strecker-sonarsource, I've seen that the PR has been merged. Thanks again! With all my admiration for the hard and competent work you did to deliver this fix. Your approach to problem-solving is truly inspiring. Best Regards |
Description
Stack Overflow on Windows
Tested on Windows 10 Enterprise and also on Windows 11 Enterprise 4vcpu 16BG ram
C:\Program Files\dotnet\sdk\8.0.200\Roslyn\Microsoft.CSharp.Core.targets(84,5): error : at SonarAnalyzer.CFG.Roslyn.
CfgAllPathValidator.b__7_0(SonarAnalyzer.CFG.Roslyn.BasicBlock)
Repro steps
Some code like https://github.com/dotnet/Open-XML-SDK/blob/main/test/DocumentFormat.OpenXml.Tests/ConformanceTest/WorkbookPr/GeneratedDocument.cs,
then
Known workarounds
Deactivating from Warning to None the rules related to CfgAllPathValidator, found searching https://github.com/search?q=repo%3ASonarSource%2Fsonar-dotnet+CfgAllPathValidator&type=pullrequests
So S3604 and S2190 set to Action None in .sonar\conf\Sonar-cs.ruleset after dotnet-sonarscanner begin
The stack overflow is does not occur on Linux (e.g. Fedora 38). Of course this is related only to the client side, not to the openjava-17 server side.
Related information
P.S. possibly related?
Known issue of the working set in Open-XML-SDK on .NET Core? => see https://github.com/dotnet/Open-XML-SDK/tree/maintab=readme-ov-file#known-issues and System.IO.Compression: ZipArchiveEntry always stores uncompressed data in memory dotnet/runtime#1544
Stack overflow in Rosyln CodeAnalysis? => see Stack overflow in Rosyln CodeAnalysis when ambiguous name is used dotnet/roslyn#71039
The text was updated successfully, but these errors were encountered: