-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
AccessViolationException in ILLink in .NET 7 #86807
Comments
Unfortunately I can't tell much from the stacktrace or binlog - I think we'll need a repro. Would you be able to share the project? @vitek-karas do you think your repro tool would be able to extract a repro from this binlog? If so, could you please share instructions with @jonathanpeppers? |
My repro tool would only work on the machine where the failure happens, since it would copy out the files from the local paths mentioned in binlog. |
I recall seeing this problem before and the workaround was to disable server GC. |
@marek-safar I think that MSBuild / I don't think we do anything to enable server GC, does the .NET SDK or MSBuild do it? (note we also are only seeing this issue on Windows) |
ILLink is configured to use server GC by default: https://github.com/dotnet/linker/blob/fdcff4c6e14b48f40011d5c8538053f84ab1d0e0/src/linker/Mono.Linker.csproj#L5 (it runs as a separate process, not hosted by MSBuild). I think you can override it with an environment variable: https://docs.microsoft.com/en-us/dotnet/core/runtime-config/garbage-collector#workstation-vs-server |
Ok, yeah if I look on disk then "configProperties": {
"System.GC.Server": true, I'll see if setting |
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 test.
Context: https://github.com/dotnet/linker/issues/3012 Context: https://github.com/dotnet/linker/issues/3012#issuecomment-1239958027 Occasionally, `AotTests.BuildAMassiveApp()` will fail, because the linker crashed: 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) … The ILLink utility is run in a separate process, and is configured to use the Server GC by default. We believe that the `AccessViolationException` is a bug in the Server GC, and the [suggested workaround][0] was to disable the server GC. Export `DOTNET_gcServer=0` so that the Server GC is disabled, in an effort to prevent the `AccessViolationException`. [0]: https://github.com/dotnet/linker/issues/3012#issuecomment-1237823998
@sbomer FYI, a PR build passed 4 times with the change above. ^^ So we merged it. So exporting |
Is there an issue tracking this in the runtime repo? I don't think we would want to work around apparent managed heap corruptions without understanding the root cause. Cc @mangod9 |
yeah if there is a dump available for this we could take a look. fyi @AntonLapounov |
It appears to only happen on Azure DevOps 1 in 3 tries or so during an integration test that runs |
You can enable collecting crash dumps by setting the registry, but I don't know how easy it would be to obtain the collected dumps from the build machines. |
Do we really support getting crash dumps by hacking the registry with admin rights only? |
@sbomer @marek-safar we started seeing this in dotnet/maui (still in .NET 7): Should we move this issue to dotnet/runtime? Worth investigating for a fix in .NET 8, etc.? |
Tagging subscribers to 'arch-android': @steveisok, @akoeplinger Issue DetailsWe 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:
I believe this started happening here: 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
|
@vitek-karas should we remove server forcing GC on desktop? If I recall the gain was not very significant and it seems to make illink unstable. |
It was 20%: dotnet/linker#1493 We should move this to the VM area. Server GC is a supported configuration option and our flagship appmodels (ASP.NET) use it by default. Is this seen only on 7.0? Or is the workaround also used in 8.0 and we don't have data? |
I don't think we've noticed this issue in .NET 8 yet (only .NET 7), but I am testing here: We have an integration test that builds an Android app with 100 class libraries -- I think it could reproduce this if I rerun it a couple times. |
Context: https://github.com/dotnet/linker/issues/3012 Context: dotnet/runtime#86807 In 34986b9, we exported `DOTNET_gcServer=0` so that the Server GC is disabled, in an effort to prevent an `AccessViolationException`. It appears that this might be *fixed* in .NET 8. Let's remove the workaround, so we can either close the issue or get further investigation on the issue.
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. |
@jonathanpeppers hoping this is ok to close now? |
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:
I believe this started happening here:
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
The text was updated successfully, but these errors were encountered: