-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
After upgrading my Mono-based runtime for s390x to preview6, using analyzers with roslyn now crashes, while it used to work in preview5.
Configuration
.NET 6 preview6 re-built to target s390x.
Regression?
Yes, this did work with preview5. Reverting the patch from #53308 fixes the problem.
Other information
The symptom is error messages along those lines:
error CS8034: Unable to load Analyzer assembly /home/uweigand/.nuget/packages/microsoft.codeanalysis.csharp.codestyle/3.10.0/analyzers/dotnet/cs/Microsoft.CodeAnalysis.CSharp.CodeStyle.dll : Object reference not set to an instance of an object
error CS8034: Unable to load Analyzer assembly /home/uweigand/.nuget/packages/microsoft.codeanalysis.csharp.codestyle/3.10.0/analyzers/dotnet/cs/Microsoft.CodeAnalysis.CodeStyle.dll : Object reference not set to an instance of an object
error CS8034: Unable to load Analyzer assembly /home/uweigand/.nuget/packages/microsoft.codeanalysis.netanalyzers/6.0.0-rc1.21356.1/analyzers/dotnet/cs/Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll : Object reference not set to an instance of an object
error CS8034: Unable to load Analyzer assembly /home/uweigand/.nuget/packages/microsoft.codeanalysis.netanalyzers/6.0.0-rc1.21356.1/analyzers/dotnet/cs/Microsoft.CodeAnalysis.NetAnalyzers.dll : Object reference not set to an instance of an object
error CS8034: Unable to load Analyzer assembly /home/uweigand/.nuget/packages/microsoft.dotnet.codeanalysis/6.0.0-beta.21359.3/analyzers/Microsoft.DotNet.CodeAnalysis.dll : Object reference not set to an instance of an object
error CS8034: Unable to load Analyzer assembly /home/uweigand/.nuget/packages/microsoft.net.illink.analyzers/6.0.100-preview.6.21362.3/analyzers/dotnet/cs/ILLink.RoslynAnalyzer.dll : Object reference not set to an instance of an object
error CS8034: Unable to load Analyzer assembly /home/uweigand/.nuget/packages/stylecop.analyzers.unstable/1.2.0.304/analyzers/dotnet/cs/StyleCop.Analyzers.dll : Object reference not set to an instance of an object
triggered in roslyn's Microsoft.CodeAnalysis.DefaultAnalyzerAssemblyLoader:LoadFromPathImpl because AssemblyLoadContext.GetLoadContext now returns null for the default ALC.
This is related to #53308. Before that patch, the default ALC used to be initialized in System.Runtime.Loader.AssemblyLoadContext:InternalInitializeNativeALC when loading the libSystem.Native library on startup.
This routine was called out of the default AssemblyLoadContext constructor (which actually allocates the handle) invoked when GetAssemblyLoadContext is called with a IntPtr.Zero handler, which happens in the MonoResolveUnmanagedDll handler, which in turn was called from netcore_resolve_with_load.
However, the above PR added this early exit to netcore_resolve_with_load:
if (!mono_gchandle_get_target_internal (alc->gchandle))
return NULL;
and now MonoResolveUnmanagedDll is never called and therefore we never actually seem to get a non-null handle.
Not sure what the proper fix is, but reverting the PR makes the problem go away.
@CoffeeFlux, @vargaz, @lambdageek can you have a look?