StackOverflow error running analysis [Re-titled from "Mismatched MVID"]

Getting the following errors:

CompilerServer: server failed - server rejected the request due to analyzer / generator issues

  • 'analyzer assembly ‘C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\2\System.Buffers.dll’ has MVID ‘36e84b0d-9d74-4086-a062-54e1963f24d5’ but loaded assembly ‘System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ has MVID ‘f389ca43-32bf-4e24-ad8c-a6ed5efddff3’, analyzer assembly
  • ‘C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\2\System.Numerics.Vectors.dll’ has MVID ‘95de52ab-0179-450a-9f6f-08d224d60b15’ but loaded assembly ‘System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ has MVID ‘34905ed1-db9d-4250-b31b-b80e1ff70ff5’, analyzer assembly
  • ‘C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\2\System.Runtime.CompilerServices.Unsafe.dll’ has MVID ‘bd600ba8-23b5-4d45-ba63-f24457fa3be3’ but loaded assembly ‘System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ has MVID ‘9dde2c5e-b52a-4cbd-861e-9aacf36593ce’’ - b78f3f01-af23-4543-9b88-67f243cc757d

Versions used:

SonarScanner for MSBuild 5.3.1
.NET Core sdk 2.1
Azure DevOps pipeline

Potential workaround:

Using the same package versions as Sonar, as mentioned here.

This is not a valid workaround for me as I do not use these packages myself, I depend on another package that uses the packages mentioned in the error, as mentioned here.

Other solutions tried:

I tried referencing the conflicting packages in my project with the same version used by Sonar (found in the github project. Like this:

<PackageReference Include="System.Buffers" Version="4.5.1" PrivateAssets="All" NoWarn="NU1605"/>

The error still appears. Using different package versions also changes nothing in the error message, the MVID mentioned for the conflicting package stays the same.

Complete log:

CoreCompile:
         C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702 /fullpaths /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;RELEASE;NETCOREAPP;NETCOREAPP2_1 /highentropyva+ / OMMITTED REFERENCES FOR READABILITY /debug- /debug:portable /filealign:512 /optimize+ /out:obj\Release\netcoreapp2.1\VensterTechniek.DAL.dll /ruleset:D:\a\1\.sonarqube\conf\Sonar-cs.ruleset /errorlog:D:\a\1\.sonarqube\out\10\Issues.json /target:library /warnaserror- /utf8output /deterministic+ /langversion:7.3 /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\0\Google.Protobuf.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\0\Newtonsoft.Json.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer.CFG.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer.CSharp.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\1\Google.Protobuf.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\1\SonarAnalyzer.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\1\SonarAnalyzer.VisualBasic.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\2\Microsoft.AspNetCore.Razor.Language.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\2\SonarAnalyzer.Security.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\2\System.Buffers.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\2\System.Memory.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\2\System.Numerics.Vectors.dll /analyzer:C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\2\System.Runtime.CompilerServices.Unsafe.dll /analyzer:C:\Users\VssAdministrator\.nuget\packages\microsoft.entityframeworkcore.analyzers\2.1.4\analyzers\dotnet\cs\Microsoft.EntityFrameworkCore.Analyzers.dll /additionalfile:D:\a\1\.sonarqube\conf\cs\SonarLint.xml /additionalfile:D:\a\1\.sonarqube\conf\10\SonarProjectConfig.xml /additionalfile:D:\a\1\.sonarqube\conf\10\ProjectOutFolderPath.txt "obj\Release\netcoreapp2.1\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs" obj\Release\netcoreapp2.1\VensterTechniek.DAL.AssemblyInfo.cs
         CompilerServer: server failed - server rejected the request due to analyzer / generator issues 'analyzer assembly 'C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\2\System.Buffers.dll' has MVID '36e84b0d-9d74-4086-a062-54e1963f24d5' but loaded assembly 'System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' has MVID 'f389ca43-32bf-4e24-ad8c-a6ed5efddff3', analyzer assembly 'C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\2\System.Numerics.Vectors.dll' has MVID '95de52ab-0179-450a-9f6f-08d224d60b15' but loaded assembly 'System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' has MVID '34905ed1-db9d-4250-b31b-b80e1ff70ff5', analyzer assembly 'C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\2\System.Runtime.CompilerServices.Unsafe.dll' has MVID 'bd600ba8-23b5-4d45-ba63-f24457fa3be3' but loaded assembly 'System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' has MVID '9dde2c5e-b52a-4cbd-861e-9aacf36593ce'' - b78f3f01-af23-4543-9b88-67f243cc757d
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): Error : 
     C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error :  [D:\a\1\s\VensterTechniek\VensterTechniek.DAL\VensterTechniek.DAL.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): Error : Process is terminated due to StackOverflowException.

Thanks,

Sander

@sbussink-covadis could you provide some more information please:

  • is this causing the build to fail?
  • are the expected issues still being uploaded to SonarQube/SonarCloud?

Also, could you provide verbose logs for the build step? Thanks.

Hello Duncan, thanks for your reply.

The issue is indeed causing the build to fail, as a StackOverflowException occurs. The results of the analyzer are not being uploaded to SonarCloud.

I’ve attached the complete log of the build step, please let me know if this verbosity level is sufficient. I might be able to make it more verbose but I’ll have to contact my collegue for that.

Thanks,

Sander

Run #20211027.5 - Build solution.txt (548.4 KB)

Thanks @Sander.

I think the “mismatched MVID” messages are unrelated to to StackOverflow exception - the MVID message appears for multiple projects, but the StackOverflow only seems to occur in VensterTechniek.DAL.csproj.

Unfortunately, there’s no information about what causes the stack overflow, but it could be an analysis rule.

Could you please:

  1. confirm that the stack overflow only occurs if you are running the SonarQube analysis, and
  2. provide a more verbose log for the build step (by passing -v:diag to msbuild.exe).

Thanks.

Hello Duncan.

I confirm the stack overflow only occurs when running the SonarCloud analysis. When turning off the SonarCloud build steps (SonarCloudPrepare, SonarCloudAnalyze and SonarCloudPublish) the build succeeds.

The verbose log of the build step is very large, so I’ve uploaded it to OneDrive. Please let me know if this is fine with you, if you’d rather have me share it another way I will do so.

https://covadis-my.sharepoint.com/:t:/g/personal/s_bussink_covadis_nl/EeXt_Gc3L3hNp_whznXv9RwBgpasaxAE4U7Kz4kpStnITA?e=2PfR5J

Thanks.

Hi @sbussink-covadis,

Unfortunately, the verbose logs don’t contain any more information about what actually caused the exception. However, the only analyzers that are running are the SonarC#, SonarVB.NET and SonarSecurity so it seems very likely that one of them is the culprit.

If it’s possible for you to share the source of the DAL project privately then we can try to work out which rule is at fault. Otherwise, we’ll have to think of some way to work out which rule is at fault.

Workaround:
As a partial workaround to upload at least some of the analysis results you could try one of the following:

(a) exclude the entire DAL project from analysis e.g.

<PropertyGroup>
  <!-- Exclude the project from analysis -->
  <SonarQubeExclude>true</SonarQubeExclude>
</PropertyGroup>

or

(b) exclude the Migrations from the DAL project
I’m guessing the Migrations are Entity-Framework files which can be very large.
You could exclude just those files by setting an appropriate source file exclusion in SonarCloud. See here for more information.

UPDATE: NB using Sonar file exclusions won’t help in the case of C#/VB.NET - the Roslyn analysis rules will still be executed by the compiler. So this won’t stop the StackOverflow exception. Thanks to @Andrei_Epure for pointing that out.

Hey @duncanp ,

I’ve excluded the DAL project from analysis using the SonarQubeExclude property and the build succeeds now. This is i.m.o. an acceptable solution for this project because it mostly contains generated code (the migrations) and entity classes which are very simple.

Thanks for the help!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.