runtime: AccessViolationException in ILLink in .NET 7
We have a integration test that builds 100 class libraries for use in an Android app. This works most of the time, but sometimes on Windows we hit:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Mono.Cecil.MetadataReader.RangesSize(Mono.Cecil.Range[])
at Mono.Cecil.MetadataReader.ReadCustomAttributes(Mono.Cecil.ICustomAttributeProvider)
at Mono.Cecil.Mixin+<>c.<GetCustomAttributes>b__13_0(Mono.Cecil.ICustomAttributeProvider, Mono.Cecil.MetadataReader)
at Mono.Cecil.ModuleDefinition.Read[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef, System.__Canon, System.Func`3<System.__Canon,Mono.Cecil.MetadataReader,System.__Canon>)
at Mono.Cecil.Mixin.GetCustomAttributes(Mono.Cecil.ICustomAttributeProvider, Mono.Collections.Generic.Collection`1<Mono.Cecil.CustomAttribute> ByRef, Mono.Cecil.ModuleDefinition)
at Mono.Cecil.MethodDefinition.get_CustomAttributes()
at Microsoft.Android.Sdk.ILLink.ApplyPreserveAttribute.GetPreserveAttributes(Mono.Cecil.ICustomAttributeProvider)
at Microsoft.Android.Sdk.ILLink.ApplyPreserveAttribute.MarkMethodIfPreserved(Mono.Cecil.MethodDefinition)
at Microsoft.Android.Sdk.ILLink.ApplyPreserveAttribute.ProcessMethod(Mono.Cecil.MethodDefinition)
at Mono.Linker.Steps.MarkSubStepsDispatcher.DispatchMethod(Mono.Cecil.MethodDefinition)
at Mono.Linker.Steps.MarkSubStepsDispatcher.BrowseTypes(Mono.Collections.Generic.Collection`1<Mono.Cecil.TypeDefinition>)
at Mono.Linker.Steps.MarkSubStepsDispatcher.BrowseTypes(Mono.Collections.Generic.Collection`1<Mono.Cecil.TypeDefinition>)
at Mono.Linker.Steps.MarkSubStepsDispatcher.BrowseAssembly(Mono.Cecil.AssemblyDefinition)
at Mono.Linker.Steps.MarkSubStepsDispatcher.<Initialize>b__5_0(Mono.Cecil.AssemblyDefinition)
at Mono.Linker.Steps.MarkStep.MarkAssembly(Mono.Cecil.AssemblyDefinition, Mono.Linker.DependencyInfo)
at Mono.Linker.Steps.MarkStep.MarkModule(Mono.Cecil.ModuleDefinition, Mono.Linker.DependencyInfo)
at Mono.Linker.Steps.MarkStep.MarkType(Mono.Cecil.TypeReference, Mono.Linker.DependencyInfo, System.Nullable`1<Mono.Linker.MessageOrigin>)
at Mono.Linker.Steps.MarkStep.ProcessMarkedPending()
at Mono.Linker.Steps.MarkStep.Initialize()
at Mono.Linker.Steps.MarkStep.Process(Mono.Linker.LinkContext)
at Mono.Linker.Pipeline.ProcessStep(Mono.Linker.LinkContext, Mono.Linker.Steps.IStep)
at Mono.Linker.Pipeline.Process(Mono.Linker.LinkContext)
at Mono.Linker.Driver.Run(Mono.Linker.ILogger)
at Mono.Linker.Driver.Main(System.String[])
Errors
C:\a\_work\1\s\bin\Release\dotnet\sdk\7.0.100-rc.1.22425.9\Sdks\Microsoft.NET.ILLink.Tasks\build\Microsoft.NET.ILLink.targets(133,5): error MSB6006: "dotnet.exe" exited with code 57005. [C:\a\_work\1\a\TestRelease\08-31_14.34.17\temp\BuildAMassiveApp\App1\App1.csproj]
OutputProperties
_ILLinkExitCode = 57005
I believe this started happening here:
- https://github.com/xamarin/xamarin-android/pull/7255
- https://github.com/dotnet/linker/compare/f09bacf...6252a21
This Maestro bump, I believe, was the first time we ever saw something like this.
Logs: accessviolation.zip
Let me know if you need the entire project, I believe the solution with 100+ class libraries is too large to attach here.
/fyi @sbomer
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (20 by maintainers)
Commits related to this issue
- [tests] export $DOTNET_gcServer as 0 Context: https://github.com/dotnet/linker/issues/3012#issuecomment-1239958027 See if disabling the "server GC" in favor of the "workstation GC" helps a failing t... — committed to jonathanpeppers/xamarin-android by jonathanpeppers 2 years ago
- [tests] export $DOTNET_gcServer as 0 (#7363) Context: https://github.com/dotnet/linker/issues/3012 Context: https://github.com/dotnet/linker/issues/3012#issuecomment-1239958027 Occasionally, `Aot... — committed to xamarin/xamarin-android by jonathanpeppers 2 years ago
- [build] stop setting `$DOTNET_gcServer` (#8085) Context: https://github.com/dotnet/linker/issues/3012 Context: https://github.com/dotnet/runtime/issues/86807 In 34986b9a, we exported `DOTNET_gcSe... — committed to xamarin/xamarin-android by jonathanpeppers a year ago
@jonathanpeppers hoping this is ok to close now?
It passed for us three times in a row using .NET 8 (main/preview 6 builds). I took out the workaround, and we’ll see if this happens again.
@sbomer @marek-safar we started seeing this in dotnet/maui (still in .NET 7):
https://github.com/dotnet/maui/pull/15275#pullrequestreview-1444770580
Should we move this issue to dotnet/runtime? Worth investigating for a fix in .NET 8, etc.?
@sbomer FYI, a PR build passed 4 times with the change above. ^^ So we merged it.
So exporting
$DOTNET_gcServer
as 0, does seem to fix the problem?We have this build artifact:
I’ll see if I can put it somewhere to share in Teams.