-
Notifications
You must be signed in to change notification settings - Fork 5k
Crash in GetHashCode with generic record #72181
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
Crash in GetHashCode with generic record #72181
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@vargaz does that ring any bells to you It seems mono does not like the compiler generated |
Would need some kind of testcase to track this down. |
C# records generate complex generic calls. @dr1rrb could you attach the compiled assembly or share what's record generated GetHashCode IL ? |
@marek-safar The source code is here https://github.com/unoplatform/uno.extensions/blob/450d19f8fd9d4c53f327e5ecddbeeb50f86b020f/src/Uno.Extensions.Reactive/Operators/FeedToListFeedAdapter.cs#L14 The issue occurs when I use one instance of this in a dictionary (and I remove the For the IL, it's a netstandard 2.0 library that is working on other platforms, that's why I sent your the whole app (with the magic of the linker ^^ - working and crashing), but here is what I get from ILSpy: For the
For the
You can find the assembly itself on nuget: https://www.nuget.org/packages/Uno.Extensions.Reactive/2.2.0-dev.8 (version dev.8 is the latest version with the bug, versions after include my workaround) |
Yes the crash happen in both debug and release. BTW, if it helps you, the source code of the app is here https://github.com/unoplatform/Uno.Samples/tree/master/reference/Uno.Extensions.Commerce (it's a sample app, you can pass the login page just by entering dummy content) In the app source code, the crash is caused by this line: https://github.com/unoplatform/Uno.Samples/blob/d29881785845b484480fc0c125a210c1cc1d5c0b/reference/Uno.Extensions.Commerce/Commerce/ViewModels/DealsViewModel.cs#L23 in the Favorites = new global::Uno.Extensions.Reactive.Bindings.BindableListFeed<Commerce.Business.Models.Product>(
nameof(Favorites),
vm.Favorites ?? throw new NullReferenceException("The list feed property 'Favorites' is null. Public feeds properties must be initialized in the constructor."),
ctx); FYI In the sample project, the generated source code can be found here: |
Commerce app crash reproI have managed to reproduce the reported issue when using Xamarin iOS with legacy mono:
I get the following error on the simulator:
With the same Managed stack trace:
The error messageFrom the error message we can see that the issue occurs in the JIT compiler. @dr1rrb Could you please try this out and confirm? Already fixed?If this is the case, then this issue seems to be the same as #57560, which was fixed for .NET6 but was not backported to mono repo. The smaller repro (on legacy mono)
using UIKit;
using System.Collections.Generic;
using System.Collections.Immutable;
using Uno.Extensions.Reactive;
namespace HelloWorld
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
var dict = new Dictionary<object, int>();
var listFeed = Feed
.Async(async ct => new[] { new object() })
.Select(list => list.ToImmutableList())
.AsListFeed();
var listFeedAsFeed = listFeed.AsFeed();
var listFeedAsFeedAsListFeed = listFeedAsFeed.AsListFeed();
var listFeedAsFeedAsListFeedAsFeed = listFeedAsFeedAsListFeed.AsFeed();
var inserted = dict.TryGetValue(listFeedAsFeedAsListFeedAsFeed, out var existing)
? existing
: (dict[listFeedAsFeedAsListFeedAsFeed] = 42);
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}
<ItemGroup>
<PackageReference Include="Uno.Extensions.Reactive" Version="2.2.0-dev.8" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0.0" />
</ItemGroup> |
I do! When I try to build the "Commerce" sample app targeting a device (in release), the OAT fails:
|
@dr1rrb The most common case is that the AOT compiler crashed. Your build logs should have some trace of that crash. The Mac's Console.app should also have a crash report for the compiler. |
The build log in VisualStudio should have a line stating the cause of the failure. From what I described above that line should be something like:
@dr1rrb it would be great if you could confirm this. |
Indeed, I didn't scroll the log enough:
So yes it's the same assertion that fails |
Hey @ivanpovazan I just tried to build the "Commerce Sample App" with the version "2.2.0-dev.70" (which contains my workaround for the I'm wondering if it's not 2 different issues. Any thoughts? (Going to try with our "simple repro") |
hey @dr1rrb, if it is failing with the same error message (mentioned above) in the fullAOT build - device build, then it is most likely the same issue. |
@ivanpovazan - other than backporting to mono\mono, does any more work remain for this for the dotnet/runtime repo for 7.0.0 ? |
@SamMonoRT, I don't think so |
No work remains for 7.0.0 @ivanpovazan will validate the fix on the mono\mono repo and close this issue. |
FYI, to workaround the build issue we do have on projects (including our sample "commerce app") I had to push my workaround further by converting my objects to Thanks for your support |
Fixes dotnet/runtime#72181 Co-authored-by: Ivan Povazan <ivan.povazan@gmail.com>
Changelog: mono-6.12.0.199 Bump nuget.exe to v6.6.1 mono-6.12.0.198 Fix xar url again (cherry picked from commit 3005442) mono-6.12.0.190 Change download URL for PCL reference assemblies mono-6.12.0.188 Bump NuGetSdkResolver in msbuild mono-6.12.0.185 Backport fixes for sharing wrappers when type attributes are involved (… …#21537) * [wasm] Fix the handling of i8/u8 in get_wrapper_shared_type_full (). (#19859) Previously, these were returned verbatim, which caused sharing issues when the type had attributes. Fixes #19841. * [aot] Fix the handling of r4/r8 parameter types with attributes during generic sharing. (#20217) The attributes need to be ignored as with the other types, otherwise gsharedvt wrappers for signatures with parameters like double f = default will not be found. Fixes #20195. mono-6.12.0.184 Backporting dotnet/runtime#59861 (#21532) Fixes dotnet/runtime#72181 mono-6.12.0.183 Backport dotnet/runtime#71436 (#21519) Backport dotnet/runtime#71436 Backport of #21516 to 2020-02
Description
In a library, I've a generic record that inherits from another generic record https://github.com/unoplatform/uno.extensions/blob/450d19f8fd9d4c53f327e5ecddbeeb50f86b020f/src/Uno.Extensions.Reactive/Operators/FeedToListFeedAdapter.cs#L14, but as soon as I try to use an instance of that record in a
Dictionary
my app is crashing.Reproduction Steps
Unfortunately I was not able to create a repro for that issue. But here are the working (with an explicit
GetHashCode
) and failing version of my app on iOS.working-Commerce.iOS.app.zip
crashing-Commerce.iOS.app.zip
.
Expected behavior
No crash :)
Actual behavior
Using mono for Android and iOS the app is crashing while using the same library is working fine on UWP / WinUI. Didn't test WebAssembly.
On Android I get a
SIGABRT
On iOS I get that stack trace:
Regression?
No response
Known Workarounds
I've implemented my own
GetHashCode
https://github.com/unoplatform/uno.extensions/blob/450d19f8fd9d4c53f327e5ecddbeeb50f86b020f/src/Uno.Extensions.Reactive/Operators/FeedToListFeedAdapter.cs#L96Configuration
Dev machine:
Win 11 21H2
VS 2022 17.3 pre 1.1
Mac:
VS for MAC 2019 v8.10.22 build 11
Simulator: iPad pro 5th gen iOS 15.4
Other information
No response
The text was updated successfully, but these errors were encountered: