Repository navigation
Description
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
[libc] Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 5768 (mmerce.Commerce), pid 5768 (mmerce.Commerce)
On iOS I get that stack trace:
=================================================================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at Uno.Extensions.Reactive.Operators.FeedToListFeedAdapter`1:GetHashCode <0x0004a>
at Uno.Extensions.Reactive.ListStateImpl`1:GetHashCode <0x0004a>
at System.Collections.Generic.ObjectEqualityComparer`1:GetHashCode <0x000aa>
at Uno.Extensions.Reactive.Operators.ListFeedToFeedAdapter`1:GetHashCode <0x0012c>
at System.Collections.Generic.Dictionary`2:FindEntry <0x001e6>
at System.Collections.Generic.Dictionary`2:TryGetValue <0x0008a>
at Uno.Extensions.Reactive.Core.StateStore:GetOrCreateState <0x0045a>
at Uno.Extensions.Reactive.Core.SourceContext:GetOrCreateStateCore <0x00375>
at Uno.Extensions.Reactive.Core.SourceContext:GetOrCreateListState <0x000fa>
at Uno.Extensions.Reactive.Bindings.BindableListFeed`1:.ctor <0x00132>
at BindableDealsViewModel:.ctor <0x006b2>
at <Module>:runtime_invoke_void__this___object_object_object <0x001ff>
at <unknown> <0xffffffff>
at System.Reflection.RuntimeConstructorInfo:InternalInvoke <0x00100>
at System.Reflection.RuntimeConstructorInfo:InternalInvoke <0x0029a>
at System.Reflection.RuntimeConstructorInfo:DoInvoke <0x004ea>
at System.Reflection.RuntimeConstructorInfo:Invoke <0x0009a>
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver:VisitConstructor <0x0038d>
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2:VisitCallSiteMain <0x00398>
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver:VisitDisposeCache <0x000dd>
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2:VisitCallSite <0x00564>
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver:Resolve <0x00237>
at <>c__DisplayClass2_0:<RealizeService>b__0 <0x000d2>
at Microsoft.Extensions.DependencyInjection.ServiceProvider:GetService <0x001eb>
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope:GetService <0x00122>
at <CreateViewModel>d__8:MoveNext <0x00c4d>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x00202>
at Uno.Extensions.Navigation.Navigators.ControlNavigator:CreateViewModel <0x0029a>
at <InitializeCurrentView>d__9:MoveNext <0x006da>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x0021a>
at Uno.Extensions.Navigation.Navigators.ControlNavigator`1:InitializeCurrentView <0x002bc>
at <NavigateForwardAsync>d__10:MoveNext <0x016a2>
at MoveNextRunner:InvokeMoveNext <0x000ab>
at System.Threading.ExecutionContext:RunInternal <0x00585>
at System.Threading.ExecutionContext:Run <0x00092>
at MoveNextRunner:Run <0x001aa>
at System.Threading.Tasks.AwaitTaskContinuation:InvokeAction <0x00093>
at System.Threading.Tasks.AwaitTaskContinuation:RunCallback <0x00153>
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run <0x0013a>
at System.Threading.Tasks.Task:FinishContinuations <0x006ae>
at System.Threading.Tasks.Task:FinishStageThree <0x0015a>
at System.Threading.Tasks.Task`1:TrySetResult <0x0026a>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult <0x002da>
at <Show>d__14:MoveNext <0x010ea>
at MoveNextRunner:InvokeMoveNext <0x000ab>
at System.Threading.ExecutionContext:RunInternal <0x00585>
at System.Threading.ExecutionContext:Run <0x00092>
at MoveNextRunner:Run <0x001aa>
at System.Threading.Tasks.AwaitTaskContinuation:InvokeAction <0x00093>
at System.Threading.Tasks.AwaitTaskContinuation:RunCallback <0x00153>
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run <0x0013a>
at System.Threading.Tasks.Task:FinishContinuations <0x006ae>
at System.Threading.Tasks.Task:FinishStageThree <0x0015a>
at System.Threading.Tasks.Task`1:TrySetResult <0x00262>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult <0x002e2>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult <0x0014a>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetResult <0x00082>
at <EnsurePageLoaded>d__15:MoveNext <0x006ba>
at MoveNextRunner:InvokeMoveNext <0x000ab>
at System.Threading.ExecutionContext:RunInternal <0x00585>
at System.Threading.ExecutionContext:Run <0x00092>
at MoveNextRunner:Run <0x001aa>
at System.Threading.Tasks.AwaitTaskContinuation:InvokeAction <0x00093>
at System.Threading.Tasks.AwaitTaskContinuation:RunCallback <0x00153>
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run <0x0013a>
at System.Threading.Tasks.Task:FinishContinuations <0x006ae>
at System.Threading.Tasks.Task:FinishStageThree <0x0015a>
at System.Threading.Tasks.Task`1:TrySetResult <0x0022a>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult <0x002b2>
at <EnsureLoaded>d__6:MoveNext <0x0088a>
at MoveNextRunner:InvokeMoveNext <0x000ab>
at System.Threading.ExecutionContext:RunInternal <0x00585>
at System.Threading.ExecutionContext:Run <0x00092>
at MoveNextRunner:Run <0x001aa>
at System.Threading.Tasks.AwaitTaskContinuation:InvokeAction <0x00093>
at System.Threading.Tasks.AwaitTaskContinuation:RunCallback <0x00153>
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run <0x0013a>
at System.Threading.Tasks.Task:FinishContinuations <0x006ae>
at System.Threading.Tasks.Task:FinishStageThree <0x0015a>
at System.Threading.Tasks.Task`1:TrySetResult <0x0022a>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult <0x002b2>
at System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1:SetResult <0x000a2>
at <ExecuteAsync>d__0`1:MoveNext <0x006f2>
at MoveNextRunner:InvokeMoveNext <0x000ab>
at System.Threading.ExecutionContext:RunInternal <0x00585>
at System.Threading.ExecutionContext:Run <0x00092>
at MoveNextRunner:Run <0x001aa>
at System.Threading.Tasks.AwaitTaskContinuation:InvokeAction <0x00093>
at System.Threading.Tasks.AwaitTaskContinuation:RunCallback <0x00153>
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run <0x0013a>
at System.Threading.Tasks.Task:FinishContinuations <0x006ae>
at System.Threading.Tasks.Task:FinishStageThree <0x0015a>
at System.Threading.Tasks.Task`1:TrySetResult <0x0022a>
at System.Threading.Tasks.TaskCompletionSource`1:TrySetResult <0x00092>
at System.Threading.Tasks.TaskCompletionSource`1:SetResult <0x0007a>
at <<ExecuteAsync>b__0>d:MoveNext <0x0046a>
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start <0x0020a>
at <>c__DisplayClass0_0`1:<ExecuteAsync>b__0 <0x0014a>
at <>c__DisplayClass6_0:<TryEnqueue>b__0 <0x0006f>
at Uno.UI.Dispatching.CoreDispatcher:InvokeOperation <0x00460>
at Uno.UI.Dispatching.CoreDispatcher:InvokeOperationSafe <0x0008a>
at Uno.UI.Dispatching.CoreDispatcher:DispatchItems <0x0070a>
at CoreFoundation.DispatchQueue:static_dispatcher_to_managed <0x0032f>
at CoreFoundation.DispatchQueue:static_dispatcher_to_managed <0x0010a>
at <unknown> <0xffffffff>
at UIKit.UIApplication:UIApplicationMain <0x00254>
at UIKit.UIApplication:Main <0x002da>
at Commerce.iOS.Application:Main <0x00092>
at <Module>:runtime_invoke_void_object <0x001a8>
=================================================================
The app has been terminated.
x
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#L96
Configuration
Dev machine:
-
Win 11 21H2
-
VS 2022 17.3 pre 1.1
Microsoft Visual Studio Enterprise 2022 Version 17.3.0 Preview 1.1 VisualStudio.17.Preview/17.3.0-pre.1.1+32519.111 Microsoft .NET Framework Version 4.8.04161 Installed Version: Enterprise Visual C++ 2022 00476-80000-00000-AA270 Microsoft Visual C++ 2022 .NET Core Debugging with WSL 1.0 .NET Core Debugging with WSL ASP.NET and Web Tools 2019 17.3.122.33185 ASP.NET and Web Tools 2019 Azure App Service Tools v3.0.0 17.3.122.33185 Azure App Service Tools v3.0.0 Azure Functions and Web Jobs Tools 17.3.122.33185 Azure Functions and Web Jobs Tools C# Tools 4.3.0-1.22254.1+9919d7e7bd753404a5d2328e5e3fb2de635169f3 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Microsoft Azure Tools for Visual Studio 2.9 Support for Azure Cloud Services projects Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Mono Debugging for Visual Studio 17.3.11 (4f73250) Support for debugging Mono processes with Visual Studio. Node.js Tools 1.5.40427.1 Commit Hash:d6dd02cc1b56ad1cb24b4ef0c48a81a985bbc64c Adds support for developing and debugging Node.js apps in Visual Studio NuGet Package Manager 6.3.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ Razor (ASP.NET Core) 17.0.0.2222701+751db1ebea5e6a9ecc7fa57fe447180422afa610 Provides languages services for ASP.NET Core Razor. SQL Server Data Tools 17.0.62204.01010 Microsoft SQL Server Data Tools TypeScript Tools 17.0.10420.2001 TypeScript Tools for Microsoft Visual Studio UnoPlatformPackage Extension 1.0 UnoPlatformPackage Visual Studio Extension Detailed Info Visual Basic Tools 4.3.0-1.22254.1+9919d7e7bd753404a5d2328e5e3fb2de635169f3 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 17.1.0-beta.22178.3+6da0245a7ce4bb8483b8d1f2993c8ecaea967ad9 Microsoft Visual F# Tools Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio. VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio VSPackage Extension 1.0 VSPackage Visual Studio Extension Detailed Info Xamarin 17.3.0.151 (d17-3-p1.1@5a59bfa) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 17.3.0.33 (remotes/origin/d17-3-1@9c0d11a29) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 17.2.15 (2e3b60e) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 12.3.99.58 (main/64b22fc) Xamarin.Android Reference Assemblies and MSBuild support. Mono: adf1bc4 Java.Interop: xamarin/java.interop/release/6.0.3xx@2a882d2d ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.38.2@7b1e016 Xamarin.Android Tools: xamarin/xamarin-android-tools/main@fc3c2ac Xamarin.iOS and Xamarin.Mac SDK 15.11.0.183 (f8314a435) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Mac:
-
VS for MAC 2019 v8.10.22 build 11
=== Visual Studio Enterprise 2019 for Mac === Version 8.10.22 (build 11) Installation UUID: eac49913-0823-40de-a49d-50b6a14dc49f GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638) Package version: 612000174 === Mono Framework MDK === Runtime: Mono 6.12.0.174 (2020-02/adf1bc4335d) (64-bit) Package version: 612000174 === Roslyn (Language Service) === 3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb === NuGet === Version: 5.9.0.7134 === .NET SDK (x64) === SDK: /usr/local/share/dotnet/sdk/5.0.407/Sdks SDK Versions: 5.0.407 5.0.404 5.0.403 5.0.400 5.0.302 5.0.103 5.0.100 3.1.418 3.1.416 3.1.415 3.1.412 3.1.411 3.1.406 3.1.302 3.1.200 MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks === .NET Core Runtime === Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 5.0.16 5.0.13 5.0.12 5.0.9 5.0.8 5.0.3 5.0.0 3.1.24 3.1.22 3.1.21 3.1.18 3.1.17 3.1.12 3.1.6 3.1.2 2.1.23 2.1.20 2.1.17 2.1.16 === .NET Core 3.1 SDK === SDK: 3.1.418 === .NET 5.0 SDK === SDK: 5.0.407 === Xamarin.Profiler === Version: 1.6.13.11 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler === Updater === Version: 11 === Xamarin.Android === Version: 12.2.4.3 (Visual Studio Enterprise) Commit: xamarin-android/d17-1/fc1125e Android SDK: /Users/david/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 8.0 (API level 26) SDK Tools Version: 26.1.1 SDK Platform Tools Version: 29.0.5 SDK Build Tools Version: 29.0.2 Build Information: Mono: adf1bc4 Java.Interop: xamarin/java.interop/d17-1@7ac33610 ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.37.1@0893b3b Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-1@db125a7 === Eclipse Temurin JDK === Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home 1.8.0.302 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL === Android SDK Manager === Version: 16.10.0.13 Hash: 1b81df5 Branch: remotes/origin/d16-10 Build date: 2021-11-12 00:17:32 UTC === Android Device Manager === Version: 16.10.0.15 Hash: 89dcc0b Branch: remotes/origin/d16-10 Build date: 2021-11-12 00:17:52 UTC === Apple Developer Tools === Xcode 13.3 (20102) Build 13E113 === Xamarin.Mac === Version: 8.8.0.3 (Visual Studio Enterprise) Hash: eb7f8ed35 Branch: xcode13.3 Build date: 2022-03-30 03:16:09-0400 === Xamarin.iOS === Version: 15.9.0.100 (Visual Studio Enterprise) Hash: cf971a68e Branch: main Build date: 2022-03-31 03:15:41-0400 === Xamarin Designer === Version: 16.11.0.60 Hash: 56f9b80b0 Branch: remotes/origin/d16-11 Build date: 2021-12-15 01:44:16 UTC === Build Information === Release ID: 810220011 Git revision: 16b49eb779f7def4523bbc8f4407628cf8dbb4b5 Build date: 2022-04-07 05:04:03-04 Build branch: release-8.10 === Operating System === Mac OS X 12.3.0 Darwin 21.4.0 Darwin Kernel Version 21.4.0 Mon Feb 21 20:34:37 PST 2022 root:xnu-8020.101.4~2/RELEASE_X86_64 x86_64 -
Simulator: iPad pro 5th gen iOS 15.4
Other information
No response
Activity
spouliot commentedon Jul 15, 2022
@vargaz does that ring any bells to you It seems mono does not like the compiler generated
GetHashCode?!? thanks!vargaz commentedon Jul 15, 2022
Would need some kind of testcase to track this down.
marek-safar commentedon Jul 18, 2022
C# records generate complex generic calls. @dr1rrb could you attach the compiled assembly or share what's record generated GetHashCode IL ?
dr1rrb commentedon Jul 19, 2022
@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
GetHashCodeI've added to workaround the issue).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
FeedToListFeedAdapter``1For the
FeedToListFeedAdapter``2You 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)
ivanpovazan commentedon Jul 25, 2022
Hello @dr1rrb, I am trying to extract your use case into a reproducible (crashing) sample as @vargaz suggested.
Would it be possible for you to provide the instantiation of
BindableListFeedwhich was causing the crash?Additionally, does this happen both in Debug and Release configurations?
dr1rrb commentedon Jul 26, 2022
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
DealsViewModelfor which we generate a nested classBindableDealsViewModelwhich will instantiate theBindableListFeeddirectly in its constructor :FYI In the sample project, the generated source code can be found here:

ivanpovazan commentedon Jul 29, 2022
Commerce app crash repro
I have managed to reproduce the reported issue when using Xamarin iOS with legacy mono:
Uno.Extensions.*to2.2.0-dev.8in the*.propsfilesCommerce.iOSin VS for Mac 2022I get the following error on the simulator:
With the same Managed stack trace:
The error message
From the error message we can see that the issue occurs in the JIT compiler.
To confirm the failure, we can also choose to target a device (if there is no actual testing device connected to the host we can choose
iOS Build Only Device:Generic Deviceconfiguration in VS) instead of the simulator, which will make the compiler build the app in fullAOT mode.The AOT compilation should fail and the same error will be reported in the build phase.
@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.
I have tried the similar-smaller repro sample (see below) on .NET7 and could not reproduce the failure I am getting on legacy mono.
@vargaz @marek-safar should this issue be moved to the https://github.com/mono/mono ?
The smaller repro (on legacy mono)
Single View Apptemplate in VisualStudioMain.cswithdr1rrb commentedon Aug 1, 2022
I do! When I try to build the "Commerce" sample app targeting a device (in release), the OAT fails:
spouliot commentedon Aug 2, 2022
@dr1rrb
MT3001is a catch-all error code of Xamarin.iOS when running the AOT compiler. Basically it means "we called the AOT compiler" but we can't find any output.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.
ivanpovazan commentedon Aug 2, 2022
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.
dr1rrb commentedon Aug 2, 2022
@spouliot @ivanpovazan
Indeed, I didn't scroll the log enough:
So yes it's the same assertion that fails
dr1rrb commentedon Aug 2, 2022
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
GetHashCode) and I noticed that the build (release - device) also fails on the AOT step. But if I target an emulator (still in release, but without AOT), the build succeed ... and my original bug (crash at runtime) is fixed.I'm wondering if it's not 2 different issues.
Any thoughts?
(Going to try with our "simple repro")
7 remaining items
dr1rrb commentedon Aug 3, 2022
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
classinstead ofrecord(and implement theGetHashCodeand theEqualsmanually). So even if for me (which is not used to deal with that kind of issues) it's not "natural" that a runtime bug can be reproduced at build time with AOT, everything tends to show that you are right ... which is a good news 👍Thanks for your support
Backporting dotnet/runtime#59861 (#21531)
Backporting dotnet/runtime#59861 (#21532)
mono: Update 6.12.0.199
Backporting dotnet/runtime#59861 (mono#21531)
Backporting dotnet/runtime#59861 (mono#21531)
Backporting dotnet/runtime#59861 (mono#21531)
Backporting dotnet/runtime#59861 (mono#21531)
Backporting dotnet/runtime#59861 (mono#21531)
Backporting dotnet/runtime#59861 (mono#21531)
mono: Update 6.12.0.199
mono: Update 6.12.0.199
mono: Update 6.12.0.199