xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.48k stars 514 forks source link

[f#] ArrayTypeMismatchException when using "Link All" in Release Mode #10342

Open charlesroddie opened 3 years ago

charlesroddie commented 3 years ago

Reproduction

In a netstandard F# project:

module M

type Style =
    | Normal = 0
    | Bold = 1
    | Italic = 2

[<RequireQualifiedAccess>]
type FE =
    | Word of string * Style * Color
    | Word3 of string
    | Space
    | SizedSpace of widthToFS:float32
    static member TryAdd() =
        let result = System.Collections.Generic.List<FE>()
        result.Add(FE.Word3 "test")

In Xamarin.iOS, call FE.TryAdd().

Expected Behavior

Nothing happens

Actual Behavior

Crash on iOS in release mode using "link all" with

SIGABRT: Attempted to access an element as a type incompatible with the array.
List`1[T].AddWithResize (T item)

With linking set to "sdk only" then the error goes away.

The same error happens with ImmutableArray.

tj-devel709 commented 3 years ago

Hello, thank you very much for your feedback.

After creating a netstandard library and calling "FE.TryAdd()" in Xamarin.iOS, I did not receive any crashes using "link all" nor "sdk only".

For us to investigate this further, could you please provide your full build logs and all your version information.

To get full build logs just set the log verbosity to diagnostic at the following locations:

On Visual Studio for Windows you also want to add -v -v -v -v to the mtouch additional arguments by right-clicking the project in the solution explorer and selecting Properties.

Note: this is done automatically on Visual Studio for Mac when the log verbosity is set to diagnostic.

The easiest way to get exact version information:

Then copy/paste the version information (you can use the "Copy Information" button).

We look forward to hearing from you!

kevcrooks commented 3 years ago

While looking through the build settings I saw "Enable the Mono Interpreter" was unticked - amazingly if we select this, the app now works. I don't understand the details of this, but is that an expected solution to our problem, and will keeping this selected have any negative impact on the size/speed of our app? If not, this solution will probably work ok for us.

But please let us know if there is a better fix?

kevcrooks commented 3 years ago

@tj-devel709 I'm attaching a zip file of a minimal sample ios solution. This loads correctly in debug mode on the simulator, but when we run in release mode on a physical ipad, it crashes on startup, since we have "Link All" set.

Does this reproduce the problem for you?

I'll delete the older comments, as this is probably an easier way to reproduce the crash testApp.zip

tj-devel709 commented 3 years ago

Hello, I appreciate the test project! I was able to unzip your attachment and run it on an iphone 12 using iOS 14.2. I could run it without enabling the mono interpreter, and using link all in release mode.

It would help if you could provide the requested information above and also the type of ipad you are testing on as well as the operating system. Thank you!

kevcrooks commented 3 years ago

Thank you @tj-devel709, I've attached the files showing my VS configuration and the build log.

I'm using an iPad A1489 running OS 12.5, however by copying the same release build settings for the a simulator, I was able to reproduce the crash on an iphons 12 using iOS 14.2 (and also on a simulator replica of my ipad).

Can you also see if you get a crash on a simulator? The app starts, shows a white screen for a short time, then exits with the exception stack.

AboutVS.txt BuildLog.txt

spouliot commented 3 years ago

Just like @tj-devel709 this works fine for me. I'm using a newer version (from main) so maybe this got fixed ?

My first guess was that the iPad A1489 is an iPad mini 2 with a 32bits ARM CPU (different compiler).

However if you're seeing this on an iPhone 12 and on simulators then it's not related to that specific hardware.

Try updating to the latest build and if it still happens please attach the symbolicated crash report (from devices) along with the device console logs.

kevcrooks commented 3 years ago

I haven't been able to run on a newer device apart from a simulator, but here is the exception log from VS when running on an iphone 12 pro iOS 14.3 simulator:

Unhandled Exception:
System.ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.
  at (wrapper stelemref) System.Object.virt_stelemref_sealed_class(intptr,object)
  at System.Collections.Generic.List`1[T].AddWithResize (T ) [0x00019] in <5068fc8a32e54286ab6bfc5ee27f556e>:0 
  at singleViewApp.AppDelegate.FinishedLaunching (UIKit.UIApplication , Foundation.NSDictionary ) [0x0000f] in <5ffc5f8ebc38dfb5a74503838e5ffc5f>:0 
--- End of stack trace from previous location where exception was thrown ---

  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] , System.IntPtr , System.IntPtr ) [0x00005] in <49835fc84e5946d2a92d26ee78137781>:0 
  at UIKit.UIApplication.Main (System.String[] , System.String , System.String ) [0x0000e] in <49835fc84e5946d2a92d26ee78137781>:0 
  at singleViewApp.Main.main (System.String[] ) [0x0
=================================================================
    Native Crash Reporting
=================================================================
Got a abrt while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
    Native stacktrace:
=================================================================
    0x10c778615 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : mono_dump_native_crash_info
    0x10c76ca9e - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : mono_handle_native_crash
    0x10c0000] in <5ffc5f8ebc38dfb5a74503838e5ffc5f>:0
2021-01-11 14:42:33.710143+0000 singleViewApp[15707:1575860] Unhandled managed exception: Attempted to access an element as a type incompatible with the array. (System.ArrayTypeMismatchException)
  at (wrapper stelemref) System.Object.virt_stelemref_sealed_class(intptr,object)
  at System.Collections.Generic.List`1[T].AddWithResize (T ) [0x00019] in <5068fc8a32e54286ab6bfc5ee27f556e>:0 
  at singleViewApp.AppDelegate.FinishedLaunching (UIKit.UIApplication , Foundation.NSDictionary ) [0x0000f] in <5ffc5f8ebc38dfb5a74503838e5ffc5f>:0 
--- End of stack trace from previous location where exception was thrown ---

  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] , System.IntPtr , System.IntPtr ) [0x00005] in <49835fc84e5946d2a92d26ee78137781>:0 
  at UIKit.UIApplication.Main (System.String[] , System.String , System.String ) [0x0000e] in <49835fc84e5946d2a92d26ee78137781>:0 
  at singleViewApp.Main.main (System.String[] ) [0x00000] in <5ffc5f8ebc38dfb5a74503838e5ffc5f>:0
777c2f - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : sigabrt_signal_handler
    0x7fff60c815fd - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_platform.dylib : _sigtramp
    0x7ffee355fe60 - Unknown
    0x7fff200fab94 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_c.dylib : abort
    0x10c98b59f - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : xamarin_unhandled_exception_handler
    0x10c82ea95 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : mono_invoke_unhandled_exception_hook
    0x10c76c4aa - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : mono_handle_exception_internal
    0x10c76a959 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : mono_handle_exception
    0x10c6eafe9 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : mono_amd64_throw_exception
    0x10cd0b5b0 - Unknown
    0x10c98b31d - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : xamarin_process_managed_exception
    0x10c991fd2 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : xamarin_invoke_trampoline
    0x10c994192 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : xamarin_arch_trampoline
    0x10c994b5a - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : xamarin_x86_64_common_trampoline
    0x7fff2468d0f1 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]
    0x7fff2468ec73 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]
    0x7fff24694681 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIApplication _runWithMainScene:transitionContext:completion:]
    0x7fff23cbd907 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]
    0x7fff2424bdb6 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : _UIScenePerformActionsWithLifecycleActionMask
    0x7fff23cbe416 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke
    0x7fff23cbde28 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
    0x7fff23cbe247 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
    0x7fff23cbdadb - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
    0x7fff23cc5d73 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
    0x7fff241556ab - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:]
    0x7fff2426865e - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : _UISceneSettingsDiffActionPerformChangesWithTransitionContext
    0x7fff23cc5a79 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
    0x7fff23ae896f - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke
    0x7fff23ae7419 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]
    0x7fff23ae85a8 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]
    0x7fff24692b20 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIApplication workspace:didCreateScene:withTransitionContext:completion:]
    0x7fff2417dab7 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:]
    0x7fff25aa20ae - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices : -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:]
    0x7fff25acab41 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices : __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.176
    0x7fff25aafad5 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices : -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
    0x7fff25aca80f - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices : __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke
    0x7fff20106508 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_client_callout
    0x7fff20109052 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_block_invoke_direct
    0x7fff25af07a5 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices : __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
    0x7fff25af048b - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices : -[FBSSerialQueue _targetQueue_performNextIfPossible]
    0x7fff25af0950 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices : -[FBSSerialQueue _performNextFromRunLoopSource]
    0x7fff2038f38a - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
    0x7fff2038f282 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : __CFRunLoopDoSource0
    0x7fff2038e764 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : __CFRunLoopDoSources0
    0x7fff20388f2f - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : __CFRunLoopRun
    0x7fff203886d6 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : CFRunLoopRunSpecific
    0x7fff2bededb3 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices : GSEventRunModal
    0x7fff24690e0b - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIApplication _run]
    0x7fff24695cbc - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : UIApplicationMain
    0x10e0a6fe4 - Unknown
    0x10e0a6e53 - Unknown
    0x10e0a3103 - Unknown
    0x10c782d51 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : mono_jit_runtime_invoke
    0x10c8a9288 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : mono_runtime_invoke_checked
    0x10c8af5f5 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : mono_runtime_exec_main_checked
    0x10c6e1b6c - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : mono_jit_exec
    0x10c993ce6 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : xamarin_main
    0x10c69bed7 - /Users/name/Library/Developer/CoreSimulator/Devices/7865D01A-2BA2-4A6A-8A32-0E648F8DB42F/data/Containers/Bundle/Application/BD7B38C0-EA32-42F8-941E-4D6600F9F406/singleViewApp.app/singleViewApp : main
    0x7fff202593e9 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdyld.dylib : start
    0x1 - Unknown

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x7fff60c5833a):0x7fff60c5832a  ff ff c3 90 90 90 b8 48 01 00 02 49 89 ca 0f 05  .......H...I....
0x7fff60c5833a  73 08 48 89 c7 e9 e5 a2 ff ff c3 90 90 90 b8 53  s.H............S
0x7fff60c5834a  00 00 02 49 89 ca 0f 05 73 08 48 89 c7 e9 cd a2  ...I....s.H.....
0x7fff60c5835a  ff ff c3 90 90 90 b8 83 01 00 02 49 89 ca 0f 05  ...........I....

=================================================================
    Managed Stacktrace:
=================================================================
=================================================================

Can you let me know how to go about updating the build that I'm using, if that is something that's still useful to try - it's strange that this only happens on my machine at the moment?

spouliot commented 3 years ago

I can reproduce it with the current preview

Xamarin.iOS
Version: 14.9.0.27 (Visual Studio Enterprise)
Hash: f4c9327fa
Branch: main
Build date: 2020-11-19 10:57:31-0500

I'll try again with the tip of main to double-check if that's already fixed (a newer mono might have included this fix).

spouliot commented 3 years ago

So I can dupe it now with main... I might have confused an already white screen (on my simulator) and missed the

error HE0042: Could not launch the app 'com.linkerFailure.singleViewApp' on the device 'iOS 14.3 (18C61) - iPhone 12': The request to open "com.linkerFailure.singleViewApp" failed.

in VS' Application Output - since I expected the longer exception to be shown (and the simulator to be back on SpringBoard).

Anyway it seems that some of the linker, release-only, optimizations do not play well with F# discriminating unions. That will need additional investigation but there's a workaround to unblock you.

Workaround

Add --optimize=-seal-and-devirtualize to the Additional mtouch arguments in your project in the Release configuration (both iPhoneSimulator and iPhone).

charlesroddie commented 3 years ago

@spouliot thanks for testing and glad you could reproduce. It was quite fiddly to get the problem, which also means that it is fairly easy to work around. For example a workaround is to use namespace M instead of module M. Hopefully this helps to identify some linker logic that isn't working, but if the linker is going to be replaced with a new one for dotnet6 (I haven't been following linker progress too closely) then it would make sense to ignore this issue.

spouliot commented 3 years ago

@charlesroddie dotnet6 has the same linker, but it's been updated. I recall some linker code was not friendly to different modules (beside the main one). That's likely the root issue since multi-module assemblies in C# are not common.