-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[android] .NET 9 p6, trimmer step no longer saving changes to disk #103987
Comments
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas |
Context: dotnet/runtime#103987
Context: dotnet/runtime#103987
Changes: dotnet/sdk@1741345...ea9243f Changes: dotnet/runtime@84b3339...117cfcc Changes: dotnet/emsdk@53288f8...9880d89 Changes: dotnet/cecil@7a4a59f...d145726 Updates: * VS.Tools.Net.Core.SDK.Resolver: from 9.0.100-preview.5.24262.2 to 9.0.100-preview.7.24323.5 * Microsoft.NETCore.App.Ref: from 9.0.0-preview.5.24256.1 to 9.0.0-preview.6.24319.11 * Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport: from 9.0.0-preview.5.24223.2 to 9.0.0-preview.6.24317.2 * Microsoft.NET.ILLink.Tasks: from 9.0.0-preview.5.24256.1 to 9.0.0-preview.6.24319.11 * Microsoft.DotNet.Cecil: from 0.11.4-alpha.24230.1 to 0.11.4-alpha.24313.1 ~~ Other changes ~~ * `$(NuGetAudit)` triggers warnings in some tests: Context: https://github.com/NuGet/docs.microsoft.com-nuget/blob/eed234f4b3edb7358e06cd2370828412a7dbd3f6/docs/concepts/Auditing-Packages.md#configuring-nuget-audit warning NU1902: Package 'Microsoft.AspNetCore.Components' 6.0.0 has a known moderate severity vulnerability, GHSA-3fx3-85r4-8j3w Bump NuGet Packages Microsoft.AspNetCore.Components.WebView to 8.0.* to fix this. * Update `*.apkdesc` files, as app size has changed slightly * `Xamarin.Android.JcwGen_Tests` fails with: Xamarin.Android.JcwGen_Tests, Xamarin.Android.JcwGenTests.BindingTests.JavaAbstractMethodTest / Release Error message System.TypeLoadException : VTable setup of type Library.MyClrCursor failed Stack trace at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object , BindingFlags ) Temporarily, ignored the test and filed: * dotnet/runtime#103987 Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com> Co-authored-by: Dean Ellis <dellis1972@googlemail.com>
Changes: dotnet/sdk@1741345...3c7b1bd Changes: dotnet/runtime@84b3339...89a244e Changes: dotnet/emsdk@53288f8...9880d89 Changes: dotnet/cecil@7a4a59f...d145726 Updates: * VS.Tools.Net.Core.SDK.Resolver: from 9.0.100-preview.5.24262.2 to 9.0.100-preview.6.24324.9 * Microsoft.NETCore.App.Ref: from 9.0.0-preview.5.24256.1 to 9.0.0-preview.6.24321.8 * Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport: from 9.0.0-preview.5.24223.2 to 9.0.0-preview.6.24319.1 * Microsoft.NET.ILLink.Tasks: from 9.0.0-preview.5.24256.1 to 9.0.0-preview.6.24321.8 * Microsoft.DotNet.Cecil: from 0.11.4-alpha.24230.1 to 0.11.4-alpha.24313.1 ~~ Other changes ~~ * `$(NuGetAudit)` triggers warnings in some tests: Context: https://github.com/NuGet/docs.microsoft.com-nuget/blob/eed234f4b3edb7358e06cd2370828412a7dbd3f6/docs/concepts/Auditing-Packages.md#configuring-nuget-audit warning NU1902: Package 'Microsoft.AspNetCore.Components' 6.0.0 has a known moderate severity vulnerability, GHSA-3fx3-85r4-8j3w Bump NuGet Packages Microsoft.AspNetCore.Components.WebView to 8.0.* to fix this. * Update `*.apkdesc` files, as app size has changed slightly * `Xamarin.Android.JcwGen_Tests` fails with: Xamarin.Android.JcwGen_Tests, Xamarin.Android.JcwGenTests.BindingTests.JavaAbstractMethodTest / Release Error message System.TypeLoadException : VTable setup of type Library.MyClrCursor failed Stack trace at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object , BindingFlags ) Temporarily, ignored the test and filed: * dotnet/runtime#103987 Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com> Co-authored-by: Dean Ellis <dellis1972@googlemail.com>
On debug build this asserts in the trimmer, but it looks unrelated to the problem:
The call comes from: This assert has been there for 3 years now - added in dotnet/linker#1768 So this is probably a long standing bug which doesn't seem to matter much - I didn't try to figure out what the assert guards against and thus what is the problem (been a while). @sbomer - probably worth filing a bug/PR in dotnet/android for this. |
(This looks to be a bit of a bug farm :-))
The method in question is and then I vaguely remember something around the Another very likely unrelated bug to the original issue here. This second assert is hit many times over on various other methods, in all cases the class name seems to include the word |
The actual problem in this case is because the added method is not marked so I looked at this:
The part I don't understand is that this behavior has been like this since forever. It's possible this has something to do with interface overrides as the added method is meant to implement This looks really weird - the output is "corrupted" I think: As you can see the It's possible that this is caused by the fact that the method is added by a custom step, since the addition happens during I think this will require either @jtschuster or @sbomer to take a deeper look. I'll send you the repro offline. |
On a related note: |
#103140 could be relevant here. |
Thank you for the repro and notes @vitek-karas! fbb67a6 introduced the specific regression. Similar to #103115 (comment), this looks like a bad interaction with custom steps and potentially with the interface logic. The custom step is relying on getting called before we build the type info for types it touches. This isn't guaranteed, and I am surprised it didn't cause problems earlier. Here's the sequence of events in the test failure:
Before fbb67a6, while processing If we want to make this guarantee we might need to build the type info cache per type, instead of per assembly, and ensure it never gets built for a type before |
If someone can share some instructions, I could try this, thanks. We just use It does seem like it would be useful for part of our CI to fail, if one of those |
Unfortunately we don't. It might be tricky to enable this. We do sometimes pass around non-shipping bits in transport packages, but building in multiple configurations can get hairy, and you have to be very careful not to depend on the non-shipping bits in any shipping configuration. It might be easier to light up these asserts based on some environment variable. |
Context: dotnet/runtime#103987 dotnet/runtime#103987 was fixed, and we should have the changes in 094bf61. Let's enable the test again.
Context: dotnet/runtime#103987 dotnet/runtime#103987 was fixed, and we should have the changes in 094bf61. Let's enable the test again.
@jonathanpeppers I want to make sure I understand the problem that |
Yes, there isn't a good public link that describes it. Ancient commit history from Xamarin says:
My understanding, it's something like:
The problem here is C# will throw So, the trimmer step goes through and adds the missing methods, and just makes them |
@sbomer and I discussed this a few weeks ago and I think the conclusion was that strictly adding default interface methods that throw wasn’t fully correct because you want the compiler to error if the user doesn’t implement all the methods. The specific case this is trying to protect against is when new interface methods were added later, in newer runtime assemblies. An alternate fix would be to produce reference assemblies with no default implementations, and impl assemblies with default implementations. Another fix would be a standalone tool that runs before the linker and does the same thing. There’s no dependency in linker behavior here. |
Yes, they would get this behavior if a NuGet package author updated their major .NET version newer and recompiled. But the problem occurs for existing NuGet packages. You can still use net8.0-android class libraries in net9.0-android apps, for example.
For this part, we would need to do something like this for NativeAOT as well, as I think there is no custom trimmer step support. What we have right now is the solution from almost a decade ago. This is something we could rework for .NET 10, if there is a good reason for removing this step. |
Description
We noticed this happening on both of these PRs:
We have a test failure:
This test is verifying that this trimmer step works:
What the trimmer step does, is attempt to "fill in" new abstract members of new Android APIs. This would allow existing net8.0-android NuGet packages to work in .NET 9, when Android adds new abstract members. (unfortunately Google does!). The general idea, is we'd prevent an exception unless the new member was actually called.
It seems like our trimmer step is doing its work:
But we don't see the changes in illink's output.
Reproduction Steps
Expected behavior
JavaAbstractMethodTest
passesActual behavior
JavaAbstractMethodTest
fails withTypeLoadException
Regression?
Yes, this worked in .NET 9 Preview 5
Known Workarounds
None
Configuration
Runtime: 9.0.0-preview.6.24321.8 or newer
Other information
.binlog
: illink-verbose.zipOutput assemblies: linked.zip
The text was updated successfully, but these errors were encountered: