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.44k stars 508 forks source link

Issues with unhandled exceptions #15252

Open mattjohnsonpint opened 2 years ago

mattjohnsonpint commented 2 years ago

Steps to Reproduce

On a Mac, after installing the latest 6.0.300 SDK and the ios workload:

  1. dotnet new ios
  2. Edit AppDelegate.cs. At the end of FinishedLaunching, before return true; insert the following code:

    AppDomain.CurrentDomain.UnhandledException += delegate
    {
        Console.WriteLine("In UnhandledException Handler");
    };
    
    AppDomain.CurrentDomain.FirstChanceException += delegate
    {
        Console.WriteLine("In FirstChanceException Handler");
    };
    
    throw new Exception("Test Exception");
  3. dotnet run

Expected Behavior

The output should indicate that the FirstChanceException handler fires once, and then the UnhandledException handler should fire once. Then I should get a crash report window from macOS (if applicable).

Actual Behavior

The log shows that the FirstChanceException handler fires over 1000 times (the exact number seems to vary). The UnhandledException handler never fires. I do get the crash report window from macOS.

Environment

Version information ``` Visual Studio Enterprise 2022 for Mac Preview Version 17.3 Preview (17.3 build 198) Installation UUID: 1a1c51f5-b451-405d-a88b-c8682f3c4d95 Runtime .NET 6.0.3 (64-bit) Architecture: Arm64 Roslyn (Language Service) 4.2.0-3.22181.8+a59a22c6f3c2cc1883e20cece412209f18f4a29f NuGet Version: 6.0.0.262 .NET SDK (Arm64) SDK: /usr/local/share/dotnet/sdk/6.0.300/Sdks SDK Version: 6.0.300 MSBuild SDKs: /usr/local/share/dotnet/sdk/6.0.300/Sdks .NET SDK (x64) SDK Versions: 6.0.300 5.0.408 3.1.419 2.1.818 .NET Runtime (Arm64) Runtime: /usr/local/share/dotnet/dotnet Runtime Version: 6.0.5 .NET Runtime (x64) Runtime: /usr/local/share/dotnet/x64/dotnet Runtime Versions: 6.0.5 5.0.17 3.1.25 2.1.30 Xamarin.Profiler Version: 1.8.0.19 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler Updater Version: 11 Apple Developer Tools Xcode 13.4.1 (20504) Build 13F100 Xamarin.Mac Version: 8.10.0.1 (Visual Studio Enterprise) Hash: 568bdb24e Branch: d17-2 Build date: 2022-04-08 18:52:56-0400 Xamarin.iOS Version: 15.10.0.1 (Visual Studio Enterprise) Hash: 568bdb24e Branch: d17-2 Build date: 2022-04-08 18:52:57-0400 Xamarin Designer Version: 17.3.0.70 Hash: 4cf1a2208 Branch: remotes/origin/d17-3 Build date: 2022-05-25 15:22:03 UTC Xamarin.Android Version: 12.3.99.58 (Visual Studio Enterprise) Commit: xamarin-android/main/64b22fc Android SDK: /Users/matt/Library/Android/sdk Supported Android versions: 12.1 (API level 32) 12.0 (API level 31) 11.0 (API level 30) 9.0 (API level 28) SDK Command-line Tools Version: 5.0 SDK Platform Tools Version: 33.0.1 SDK Build Tools Version: 33.0.0 rc4 Build Information: 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 Microsoft Build of OpenJDK Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk 11.0.15 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Eclipse Temurin JDK Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk 1.8.0.302 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Android SDK Manager Version: 17.2.0.47 Hash: d6dd135 Branch: remotes/origin/dev/tondat/main-1512059~2 Build date: 2022-05-25 15:21:57 UTC Android Device Manager Version: 0.0.0.1127 Hash: 4bb4d48 Branch: remotes/origin/dev/tondat/main-1536295~1 Build date: 2022-05-25 15:21:57 UTC Build Information Release ID: 1703000198 Git revision: b61a5879556b3b4d5270ffffd9431e5ec7db233d Build date: 2022-05-25 15:20:15+00 Build branch: release-17.3 Build lane: release-17.3 Operating System Mac OS X 12.4.0 Darwin 21.5.0 Darwin Kernel Version 21.5.0 Tue Apr 26 21:08:37 PDT 2022 root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64 ```
Crash Report ``` ------------------------------------- Translated Report (Full Report Below) ------------------------------------- Incident Identifier: A43C9AF2-C7F0-4138-8A6F-13803FED9E14 CrashReporter Key: 033C27F8-F8D2-CF5C-D530-420FAA271D3D Hardware Model: MacBookPro18,1 Process: IosApp1 [88916] Path: /Users/USER/Library/Developer/CoreSimulator/Devices/02F1B274-3BDC-471F-9304-EC96459FB2BC/data/Containers/Bundle/Application/8F088341-30E9-4168-81FF-61B555F0DF29/IosApp1.app/IosApp1 Identifier: com.companyname.IosApp1 Version: 1.0 (1.0) Code Type: X86-64 (Native) Role: Foreground Parent Process: launchd_sim [25203] Coalition: com.apple.CoreSimulator.SimDevice.02F1B274-3BDC-471F-9304-EC96459FB2BC [9251] Responsible Process: SimulatorTrampoline [1443] Date/Time: 2022-06-11 15:36:42.3685 -0700 Launch Time: 2022-06-11 15:36:39.7411 -0700 OS Version: macOS 12.4 (21F79) Release Type: User Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_PROTECTION_FAILURE at 0x000000030c5dbb34 Exception Codes: 0x0000000000000002, 0x000000030c5dbb34 VM Region Info: 0x30c5dbb34 is in 0x308dd8000-0x30c5dc000; bytes after start: 58735412 bytes before end: 1227 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL unused shlib __TEXT 2049c2000-2049c5000 [ 12K] r--/r-- SM=NUL ... this process GAP OF 0x104413000 BYTES ---> Stack Guard 308dd8000-30c5dc000 [ 56.0M] ---/rwx SM=NUL Stack 30c5dc000-30cdd8000 [ 8176K] rw-/rwx SM=PRV Exception Note: EXC_CORPSE_NOTIFY Termination Reason: SIGNAL 11 Segmentation fault: 11 Terminating Process: exc handler [88916] Triggered by Thread: 0 Last Exception Backtrace: 0 CoreFoundation 0x11196e5f4 __exceptionPreprocess + 226 1 libobjc.A.dylib 0x11e8f5a45 objc_exception_throw + 48 2 libxamarin-dotnet-debug.dylib 0x10d3e4f6f xamarin_process_managed_exception + 943 3 libxamarin-dotnet-debug.dylib 0x10d3f1a42 xamarin_invoke_trampoline + 8578 4 libxamarin-dotnet-debug.dylib 0x10d3f90b9 xamarin_arch_trampoline + 105 5 libxamarin-dotnet-debug.dylib 0x10d3fa29e xamarin_x86_64_common_trampoline + 118 6 UIKitCore 0x12a048593 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 214 7 UIKitCore 0x12a04a284 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 4128 8 UIKitCore 0x12a04fc24 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1190 9 UIKitCore 0x1295c046a -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122 10 UIKitCore 0x129bb4592 _UIScenePerformActionsWithLifecycleActionMask + 88 11 UIKitCore 0x1295c0f64 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198 12 UIKitCore 0x1295c09a1 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 252 13 UIKitCore 0x1295c0d9a -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 831 14 UIKitCore 0x1295c0647 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 354 15 UIKitCore 0x1295caa8f __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 178 16 UIKitCore 0x129a97b01 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 859 17 UIKitCore 0x129bd1a19 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 246 18 UIKitCore 0x1295ca713 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 346 19 UIKitCore 0x1293c7af5 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.578 + 796 20 UIKitCore 0x1293c64c7 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 253 21 UIKitCore 0x1293c76b5 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 255 22 UIKitCore 0x12a04e545 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 513 23 UIKitCore 0x129ac8afe -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 355 24 FrontBoardServices 0x12028bcdd -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 415 25 FrontBoardServices 0x1202b8216 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.180 + 102 26 FrontBoardServices 0x12029a0ef -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 209 27 FrontBoardServices 0x1202b7df5 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 352 28 libdispatch.dylib 0x11dacdb25 _dispatch_client_callout + 8 29 libdispatch.dylib 0x11dad0c9f _dispatch_block_invoke_direct + 281 30 FrontBoardServices 0x1202deda3 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30 31 FrontBoardServices 0x1202dec99 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 174 32 FrontBoardServices 0x1202dedcb -[FBSSerialQueue _performNextFromRunLoopSource] + 19 33 CoreFoundation 0x1118db4a7 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 34 CoreFoundation 0x1118db39f __CFRunLoopDoSource0 + 180 35 CoreFoundation 0x1118da86c __CFRunLoopDoSources0 + 242 36 CoreFoundation 0x1118d4f68 __CFRunLoopRun + 871 37 CoreFoundation 0x1118d4704 CFRunLoopRunSpecific + 562 38 GraphicsServices 0x1207ccc8e GSEventRunModal + 139 39 UIKitCore 0x12a04c65a -[UIApplication _run] + 928 40 UIKitCore 0x12a0512b5 UIApplicationMain + 101 41 ??? 0x15bd78111 ??? 42 ??? 0x15bd75453 ??? 43 libmonosgen-2.0.dylib 0x10dab9fff mono_jit_runtime_invoke + 2223 44 libmonosgen-2.0.dylib 0x10d9dc318 mono_runtime_invoke_checked + 136 45 libmonosgen-2.0.dylib 0x10d9e30bb mono_runtime_exec_main_checked + 107 46 libmonosgen-2.0.dylib 0x10db1c0b2 mono_jit_exec + 354 47 libxamarin-dotnet-debug.dylib 0x10d3f8f0d xamarin_main + 1949 48 IosApp1 0x1044b1ac4 main + 52 (main.x86_64.mm:65) 49 dyld_sim 0x10cfccf21 start_sim + 10 50 dyld 0x20491251e start + 462 51 ??? 0x3 ??? Thread 0 Crashed:: tid_103 Dispatch queue: com.apple.main-thread 0 0x104b6ef08 ??? 1 0x104d94608 ??? 2 libsystem_trace.dylib 0x11eb0a252 _os_log_with_args_impl + 466 3 CoreFoundation 0x11194ba7e _CFLogvEx3 + 198 4 Foundation 0x11490b328 _NSLogv + 97 5 Foundation 0x11490b3c6 NSLog + 138 6 libSystem.Native.dylib 0x10cefc96a SystemNative_Log + 218 7 ??? 0x161fa4056 ??? Thread 1:: com.apple.rosetta.exceptionserver 0 ??? 0x7ff7ffd389c4 ??? 1 ??? 0x7ff7ffd51208 ??? Thread 2: 0 ??? 0x7ff7ffd56814 ??? Thread 3:: SGen worker 0 ??? 0x10489d940 ??? 1 0x104e3f814 ??? 2 libsystem_pthread.dylib 0x11f35fa6f _pthread_cond_wait + 1249 3 libmonosgen-2.0.dylib 0x10daa0e93 thread_func + 243 4 libsystem_pthread.dylib 0x11f35f4e1 _pthread_start + 125 5 libsystem_pthread.dylib 0x11f35af6b thread_start + 15 Thread 4:: Finalizer 0 ??? 0x10489d940 ??? 1 0x104e2b75c ??? 2 libmonosgen-2.0.dylib 0x10da1e07b finalizer_thread + 299 3 libmonosgen-2.0.dylib 0x10d9f4853 start_wrapper_internal + 371 4 libmonosgen-2.0.dylib 0x10d9f46be start_wrapper + 62 5 libsystem_pthread.dylib 0x11f35f4e1 _pthread_start + 125 6 libsystem_pthread.dylib 0x11f35af6b thread_start + 15 Thread 5: 0 ??? 0x7ff7ffd56814 ??? Thread 6: 0 ??? 0x7ff7ffd56814 ??? Thread 7:: com.apple.uikit.eventfetch-thread 0 ??? 0x10489d940 ??? 1 0x10492568c ??? 2 libsystem_kernel.dylib 0x11f2bbce8 mach_msg + 56 3 CoreFoundation 0x1118daacc __CFRunLoopServiceMachPort + 319 4 CoreFoundation 0x1118d50e2 __CFRunLoopRun + 1249 5 CoreFoundation 0x1118d4704 CFRunLoopRunSpecific + 562 6 Foundation 0x114936049 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 213 7 Foundation 0x1149362c2 -[NSRunLoop(NSRunLoop) runUntilDate:] + 72 8 UIKitCore 0x12a10fbda -[UIEventFetcher threadMain] + 491 9 Foundation 0x11495f1a1 __NSThread__start__ + 1009 10 libsystem_pthread.dylib 0x11f35f4e1 _pthread_start + 125 11 libsystem_pthread.dylib 0x11f35af6b thread_start + 15 Thread 8: 0 ??? 0x7ff7ffd56814 ??? Thread 9:: Dispatch queue: com.apple.UIKit.KeyboardManagement 0 ??? 0x10489d940 ??? 1 0x105c75754 ??? 2 libdispatch.dylib 0x11dace2b6 _dlock_wait + 45 3 libdispatch.dylib 0x11dace118 _dispatch_thread_event_wait_slow + 40 4 libdispatch.dylib 0x11dadbfbe __DISPATCH_WAIT_FOR_QUEUE__ + 326 5 libdispatch.dylib 0x11dadbb39 _dispatch_sync_f_slow + 202 6 UIKitCore 0x129e67b26 __37-[_UIRemoteKeyboards startConnection]_block_invoke_3 + 98 7 CoreFoundation 0x111974fdc __invoking___ + 140 8 CoreFoundation 0x11197234f -[NSInvocation invoke] + 305 9 Foundation 0x114a310ca __NSXPCCONNECTION_IS_CALLING_OUT_TO_REPLY_BLOCK__ + 17 10 Foundation 0x114a30ca1 -[NSXPCConnection _decodeAndInvokeReplyBlockWithEvent:sequence:replyInfo:] + 629 11 Foundation 0x114a35710 __88-[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:]_block_invoke_3 + 205 12 libxpc.dylib 0x11f3ab07e _xpc_connection_reply_callout + 36 13 libxpc.dylib 0x11f3a0578 _xpc_connection_call_reply_async + 69 14 libdispatch.dylib 0x11dacdb8b _dispatch_client_callout3 + 8 15 libdispatch.dylib 0x11dae8fa6 _dispatch_mach_msg_async_reply_invoke + 397 16 libdispatch.dylib 0x11dad3f65 _dispatch_lane_serial_drain + 375 17 libdispatch.dylib 0x11dad4cf8 _dispatch_lane_invoke + 455 18 libdispatch.dylib 0x11dadf97b _dispatch_workloop_worker_thread + 779 19 libsystem_pthread.dylib 0x11f35bfd0 _pthread_wqthread + 326 20 libsystem_pthread.dylib 0x11f35af57 start_wqthread + 15 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x000000030c5dcdc0 rbx: 0x000000010cefd689 rcx: 0x0000000040000000 rdx: 0x0000000000000000 rdi: 0x000000030c5dcd10 rsi: 0x000000011eb125d0 rbp: 0x000000030c5dccf0 rsp: 0x000000030c5dba20 r8: 0x000000030c5dcdc0 r9: 0x000000000000000c r10: 0x000000010d0ba280 r11: 0x00000001118b3826 r12: 0x0000000040000000 r13: 0x000000010ceee000 r14: 0x000000010cefe510 r15: 0x0000000000000000 rip: rfl: 0x0000000000000202 tmp0: 0xffffffffffffee44 tmp1: 0x0000000104d949e0 tmp2: 0x000000011eb0a252 Binary Images: 0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ??? 0x11eaf7000 - 0x11eb0ffff libsystem_trace.dylib (*) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_trace.dylib 0x111859000 - 0x111c5efff com.apple.CoreFoundation (6.9) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 0x114812000 - 0x114b06fff com.apple.Foundation (6.9) <9827fa7d-2500-32d7-aaaf-288e38b126ab> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Foundation 0x10ceee000 - 0x10cefdfff libSystem.Native.dylib (*) /Users/USER/Library/Developer/CoreSimulator/Devices/02F1B274-3BDC-471F-9304-EC96459FB2BC/data/Containers/Bundle/Application/8F088341-30E9-4168-81FF-61B555F0DF29/IosApp1.app/libSystem.Native.dylib 0x11f359000 - 0x11f364fff libsystem_pthread.dylib (*) /usr/lib/system/libsystem_pthread.dylib 0x10d967000 - 0x10de1efff libmonosgen-2.0.dylib (*) <5344b178-6c90-3cd7-b92c-8f228acb48d2> /Users/USER/Library/Developer/CoreSimulator/Devices/02F1B274-3BDC-471F-9304-EC96459FB2BC/data/Containers/Bundle/Application/8F088341-30E9-4168-81FF-61B555F0DF29/IosApp1.app/libmonosgen-2.0.dylib 0x11f2ba000 - 0x11f2f1fff libsystem_kernel.dylib (*) <61711d11-e776-3bc3-b9a2-6f9f37cb8499> /usr/lib/system/libsystem_kernel.dylib 0x129371000 - 0x12abfffff com.apple.UIKitCore (1.0) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore 0x11dacb000 - 0x11db11fff libdispatch.dylib (*) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib 0x11f395000 - 0x11f3c8fff libxpc.dylib (*) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libxpc.dylib 0x11e8d5000 - 0x11e907fff libobjc.A.dylib (*) <791e787b-f11e-36d6-925b-5c10df76d693> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libobjc.A.dylib 0x10d3b1000 - 0x10d400fff libxamarin-dotnet-debug.dylib (*) /Users/USER/Library/Developer/CoreSimulator/Devices/02F1B274-3BDC-471F-9304-EC96459FB2BC/data/Containers/Bundle/Application/8F088341-30E9-4168-81FF-61B555F0DF29/IosApp1.app/libxamarin-dotnet-debug.dylib 0x120283000 - 0x12031ffff com.apple.FrontBoardServices (765.10) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices 0x1207c9000 - 0x1207d1fff com.apple.GraphicsServices (1.0) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices 0x104413000 - 0x1044fafff com.companyname.IosApp1 (1.0) <9ea51796-b474-309b-a99d-38a0614ca8df> /Users/USER/Library/Developer/CoreSimulator/Devices/02F1B274-3BDC-471F-9304-EC96459FB2BC/data/Containers/Bundle/Application/8F088341-30E9-4168-81FF-61B555F0DF29/IosApp1.app/IosApp1 0x10cfcb000 - 0x10d018fff dyld_sim (*) <7276a69b-e3b9-3f23-957f-061350a501b4> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim 0x20490d000 - 0x204978fff dyld (*) /usr/lib/dyld Error Formulating Crash Report: dyld_process_snapshot_get_shared_cache failed EOF ----------- Full Report ----------- {"app_name":"IosApp1","timestamp":"2022-06-11 15:36:48.00 -0700","app_version":"1.0","slice_uuid":"9ea51796-b474-309b-a99d-38a0614ca8df","build_version":"1.0","platform":7,"bundleID":"com.companyname.IosApp1","share_with_app_devs":1,"is_first_party":0,"bug_type":"309","os_version":"macOS 12.4 (21F79)","incident_id":"A43C9AF2-C7F0-4138-8A6F-13803FED9E14","name":"IosApp1"} { "uptime" : 83000, "procLaunch" : "2022-06-11 15:36:39.7411 -0700", "procRole" : "Foreground", "version" : 2, "userID" : 501, "deployVersion" : 210, "modelCode" : "MacBookPro18,1", "procStartAbsTime" : 2011719147838, "coalitionID" : 9251, "osVersion" : { "train" : "macOS 12.4", "build" : "21F79", "releaseType" : "User" }, "captureTime" : "2022-06-11 15:36:42.3685 -0700", "incident" : "A43C9AF2-C7F0-4138-8A6F-13803FED9E14", "bug_type" : "309", "pid" : 88916, "procExitAbsTime" : 2011782157779, "translated" : true, "cpuType" : "X86-64", "procName" : "IosApp1", "procPath" : "\/Users\/USER\/Library\/Developer\/CoreSimulator\/Devices\/02F1B274-3BDC-471F-9304-EC96459FB2BC\/data\/Containers\/Bundle\/Application\/8F088341-30E9-4168-81FF-61B555F0DF29\/IosApp1.app\/IosApp1", "bundleInfo" : {"CFBundleShortVersionString":"1.0","CFBundleVersion":"1.0","CFBundleIdentifier":"com.companyname.IosApp1"}, "storeInfo" : {"deviceIdentifierForVendor":"218C79D0-1436-52E9-BDDA-F7E854AC6CEF","thirdParty":true}, "parentProc" : "launchd_sim", "parentPid" : 25203, "coalitionName" : "com.apple.CoreSimulator.SimDevice.02F1B274-3BDC-471F-9304-EC96459FB2BC", "crashReporterKey" : "033C27F8-F8D2-CF5C-D530-420FAA271D3D", "responsiblePid" : 1443, "responsibleProc" : "SimulatorTrampoline", "sip" : "enabled", "vmRegionInfo" : "0x30c5dbb34 is in 0x308dd8000-0x30c5dc000; bytes after start: 58735412 bytes before end: 1227\n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n unused shlib __TEXT 2049c2000-2049c5000 [ 12K] r--\/r-- SM=NUL ... this process\n GAP OF 0x104413000 BYTES\n---> Stack Guard 308dd8000-30c5dc000 [ 56.0M] ---\/rwx SM=NUL \n Stack 30c5dc000-30cdd8000 [ 8176K] rw-\/rwx SM=PRV ", "isCorpse" : 1, "exception" : {"codes":"0x0000000000000002, 0x000000030c5dbb34","rawCodes":[2,13092371252],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_PROTECTION_FAILURE at 0x000000030c5dbb34"}, "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":88916}, "vmregioninfo" : "0x30c5dbb34 is in 0x308dd8000-0x30c5dc000; bytes after start: 58735412 bytes before end: 1227\n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n unused shlib __TEXT 2049c2000-2049c5000 [ 12K] r--\/r-- SM=NUL ... this process\n GAP OF 0x104413000 BYTES\n---> Stack Guard 308dd8000-30c5dc000 [ 56.0M] ---\/rwx SM=NUL \n Stack 30c5dc000-30cdd8000 [ 8176K] rw-\/rwx SM=PRV ", "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":1},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0}, "lastExceptionBacktrace" : [{"imageOffset":1136116,"symbol":"__exceptionPreprocess","symbolLocation":226,"imageIndex":2},{"imageOffset":133701,"symbol":"objc_exception_throw","symbolLocation":48,"imageIndex":11},{"imageOffset":212847,"symbol":"xamarin_process_managed_exception","symbolLocation":943,"imageIndex":12},{"imageOffset":264770,"symbol":"xamarin_invoke_trampoline","symbolLocation":8578,"imageIndex":12},{"imageOffset":295097,"symbol":"xamarin_arch_trampoline","symbolLocation":105,"imageIndex":12},{"imageOffset":299678,"symbol":"xamarin_x86_64_common_trampoline","symbolLocation":118,"imageIndex":12},{"imageOffset":13464979,"symbol":"-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]","symbolLocation":214,"imageIndex":8},{"imageOffset":13472388,"symbol":"-[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]","symbolLocation":4128,"imageIndex":8},{"imageOffset":13495332,"symbol":"-[UIApplication _runWithMainScene:transitionContext:completion:]","symbolLocation":1190,"imageIndex":8},{"imageOffset":2421866,"symbol":"-[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]","symbolLocation":122,"imageIndex":8},{"imageOffset":8664466,"symbol":"_UIScenePerformActionsWithLifecycleActionMask","symbolLocation":88,"imageIndex":8},{"imageOffset":2424676,"symbol":"__101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke","symbolLocation":198,"imageIndex":8},{"imageOffset":2423201,"symbol":"-[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]","symbolLocation":252,"imageIndex":8},{"imageOffset":2424218,"symbol":"-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]","symbolLocation":831,"imageIndex":8},{"imageOffset":2422343,"symbol":"-[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]","symbolLocation":354,"imageIndex":8},{"imageOffset":2464399,"symbol":"__186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke","symbolLocation":178,"imageIndex":8},{"imageOffset":7498497,"symbol":"+[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:]","symbolLocation":859,"imageIndex":8},{"imageOffset":8784409,"symbol":"_UISceneSettingsDiffActionPerformChangesWithTransitionContext","symbolLocation":246,"imageIndex":8},{"imageOffset":2463507,"symbol":"-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]","symbolLocation":346,"imageIndex":8},{"imageOffset":355061,"symbol":"__64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.578","symbolLocation":796,"imageIndex":8},{"imageOffset":349383,"symbol":"-[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]","symbolLocation":253,"imageIndex":8},{"imageOffset":353973,"symbol":"-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]","symbolLocation":255,"imageIndex":8},{"imageOffset":13489477,"symbol":"-[UIApplication workspace:didCreateScene:withTransitionContext:completion:]","symbolLocation":513,"imageIndex":8},{"imageOffset":7699198,"symbol":"-[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:]","symbolLocation":355,"imageIndex":8},{"imageOffset":36061,"symbol":"-[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:]","symbolLocation":415,"imageIndex":13},{"imageOffset":217622,"symbol":"__94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.180","symbolLocation":102,"imageIndex":13},{"imageOffset":94447,"symbol":"-[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]","symbolLocation":209,"imageIndex":13},{"imageOffset":216565,"symbol":"__94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke","symbolLocation":352,"imageIndex":13},{"imageOffset":11045,"symbol":"_dispatch_client_callout","symbolLocation":8,"imageIndex":9},{"imageOffset":23711,"symbol":"_dispatch_block_invoke_direct","symbolLocation":281,"imageIndex":9},{"imageOffset":376227,"symbol":"__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__","symbolLocation":30,"imageIndex":13},{"imageOffset":375961,"symbol":"-[FBSSerialQueue _targetQueue_performNextIfPossible]","symbolLocation":174,"imageIndex":13},{"imageOffset":376267,"symbol":"-[FBSSerialQueue _performNextFromRunLoopSource]","symbolLocation":19,"imageIndex":13},{"imageOffset":533671,"symbol":"__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__","symbolLocation":17,"imageIndex":2},{"imageOffset":533407,"symbol":"__CFRunLoopDoSource0","symbolLocation":180,"imageIndex":2},{"imageOffset":530540,"symbol":"__CFRunLoopDoSources0","symbolLocation":242,"imageIndex":2},{"imageOffset":507752,"symbol":"__CFRunLoopRun","symbolLocation":871,"imageIndex":2},{"imageOffset":505604,"symbol":"CFRunLoopRunSpecific","symbolLocation":562,"imageIndex":2},{"imageOffset":15502,"symbol":"GSEventRunModal","symbolLocation":139,"imageIndex":14},{"imageOffset":13481562,"symbol":"-[UIApplication _run]","symbolLocation":928,"imageIndex":8},{"imageOffset":13501109,"symbol":"UIApplicationMain","symbolLocation":101,"imageIndex":8},{"imageOffset":5835817233,"imageIndex":0},{"imageOffset":5835805779,"imageIndex":0},{"imageOffset":1388543,"symbol":"mono_jit_runtime_invoke","symbolLocation":2223,"imageIndex":6},{"imageOffset":480024,"symbol":"mono_runtime_invoke_checked","symbolLocation":136,"imageIndex":6},{"imageOffset":508091,"symbol":"mono_runtime_exec_main_checked","symbolLocation":107,"imageIndex":6},{"imageOffset":1790130,"symbol":"mono_jit_exec","symbolLocation":354,"imageIndex":6},{"imageOffset":294669,"symbol":"xamarin_main","symbolLocation":1949,"imageIndex":12},{"imageOffset":649924,"sourceLine":65,"sourceFile":"main.x86_64.mm","symbol":"main","imageIndex":15,"symbolLocation":52},{"imageOffset":7969,"symbol":"start_sim","symbolLocation":10,"imageIndex":16},{"imageOffset":21790,"symbol":"start","symbolLocation":462,"imageIndex":17},{"imageOffset":3,"imageIndex":0}], "faultingThread" : 0, "threads" : [{"triggered":true,"id":1419438,"threadState":{"flavor":"x86_THREAD_STATE","rbp":{"value":13092375792},"r12":{"value":1073741824},"rosetta":{"tmp2":{"value":4809859666},"tmp1":{"value":4376316384},"tmp0":{"value":18446744073709547076}},"rbx":{"value":4512011913},"r8":{"value":13092376000},"r15":{"value":0},"r10":{"value":4513833600},"rdx":{"value":0},"rdi":{"value":13092375824},"r9":{"value":12},"r13":{"value":4511948800},"rflags":{"value":514},"rax":{"value":13092376000},"rsp":{"value":13092370976},"r11":{"value":4589303846,"symbolLocation":0,"symbol":"-[__NSCFString _fastCStringContents:]"},"rcx":{"value":1073741824},"r14":{"value":4512015632},"rsi":{"value":4809893328,"symbolLocation":0,"symbol":"_os_log_default"}},"name":"tid_103","queue":"com.apple.main-thread","frames":[{"imageOffset":4374064904,"region":"","imageIndex":0},{"imageOffset":4376315400,"region":"","imageIndex":0},{"imageOffset":78418,"symbol":"_os_log_with_args_impl","symbolLocation":466,"imageIndex":1},{"imageOffset":993918,"symbol":"_CFLogvEx3","symbolLocation":198,"imageIndex":2},{"imageOffset":1020712,"symbol":"_NSLogv","symbolLocation":97,"imageIndex":3},{"imageOffset":1020870,"symbol":"NSLog","symbolLocation":138,"imageIndex":3},{"imageOffset":59754,"symbol":"SystemNative_Log","symbolLocation":218,"imageIndex":4},{"imageOffset":5938757718,"imageIndex":0}]},{"id":1419474,"name":"com.apple.rosetta.exceptionserver","frames":[{"imageOffset":140703125703108,"imageIndex":0},{"imageOffset":140703125803528,"imageIndex":0}]},{"id":1419487,"frames":[{"imageOffset":140703125825556,"imageIndex":0}]},{"id":1419489,"name":"SGen worker","frames":[{"imageOffset":4371110208,"imageIndex":0},{"imageOffset":4377016340,"region":"","imageIndex":0},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":1285779,"symbol":"thread_func","symbolLocation":243,"imageIndex":6},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":1419490,"name":"Finalizer","frames":[{"imageOffset":4371110208,"imageIndex":0},{"imageOffset":4376934236,"region":"","imageIndex":0},{"imageOffset":749691,"symbol":"finalizer_thread","symbolLocation":299,"imageIndex":6},{"imageOffset":579667,"symbol":"start_wrapper_internal","symbolLocation":371,"imageIndex":6},{"imageOffset":579262,"symbol":"start_wrapper","symbolLocation":62,"imageIndex":6},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":1419495,"frames":[{"imageOffset":140703125825556,"imageIndex":0}]},{"id":1419496,"frames":[{"imageOffset":140703125825556,"imageIndex":0}]},{"id":1419497,"name":"com.apple.uikit.eventfetch-thread","frames":[{"imageOffset":4371110208,"imageIndex":0},{"imageOffset":4371666572,"region":"","imageIndex":0},{"imageOffset":7400,"symbol":"mach_msg","symbolLocation":56,"imageIndex":7},{"imageOffset":531148,"symbol":"__CFRunLoopServiceMachPort","symbolLocation":319,"imageIndex":2},{"imageOffset":508130,"symbol":"__CFRunLoopRun","symbolLocation":1249,"imageIndex":2},{"imageOffset":505604,"symbol":"CFRunLoopRunSpecific","symbolLocation":562,"imageIndex":2},{"imageOffset":1196105,"symbol":"-[NSRunLoop(NSRunLoop) runMode:beforeDate:]","symbolLocation":213,"imageIndex":3},{"imageOffset":1196738,"symbol":"-[NSRunLoop(NSRunLoop) runUntilDate:]","symbolLocation":72,"imageIndex":3},{"imageOffset":14281690,"symbol":"-[UIEventFetcher threadMain]","symbolLocation":491,"imageIndex":8},{"imageOffset":1364385,"symbol":"__NSThread__start__","symbolLocation":1009,"imageIndex":3},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":1419500,"frames":[{"imageOffset":140703125825556,"imageIndex":0}]},{"id":1419501,"queue":"com.apple.UIKit.KeyboardManagement","frames":[{"imageOffset":4371110208,"imageIndex":0},{"imageOffset":4391917396,"region":"","imageIndex":0},{"imageOffset":12982,"symbol":"_dlock_wait","symbolLocation":45,"imageIndex":9},{"imageOffset":12568,"symbol":"_dispatch_thread_event_wait_slow","symbolLocation":40,"imageIndex":9},{"imageOffset":69566,"symbol":"__DISPATCH_WAIT_FOR_QUEUE__","symbolLocation":326,"imageIndex":9},{"imageOffset":68409,"symbol":"_dispatch_sync_f_slow","symbolLocation":202,"imageIndex":9},{"imageOffset":11496230,"symbol":"__37-[_UIRemoteKeyboards startConnection]_block_invoke_3","symbolLocation":98,"imageIndex":8},{"imageOffset":1163228,"symbol":"__invoking___","symbolLocation":140,"imageIndex":2},{"imageOffset":1151823,"symbol":"-[NSInvocation invoke]","symbolLocation":305,"imageIndex":2},{"imageOffset":2224330,"symbol":"__NSXPCCONNECTION_IS_CALLING_OUT_TO_REPLY_BLOCK__","symbolLocation":17,"imageIndex":3},{"imageOffset":2223265,"symbol":"-[NSXPCConnection _decodeAndInvokeReplyBlockWithEvent:sequence:replyInfo:]","symbolLocation":629,"imageIndex":3},{"imageOffset":2242320,"symbol":"__88-[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:]_block_invoke_3","symbolLocation":205,"imageIndex":3},{"imageOffset":90238,"symbol":"_xpc_connection_reply_callout","symbolLocation":36,"imageIndex":10},{"imageOffset":46456,"symbol":"_xpc_connection_call_reply_async","symbolLocation":69,"imageIndex":10},{"imageOffset":11147,"symbol":"_dispatch_client_callout3","symbolLocation":8,"imageIndex":9},{"imageOffset":122790,"symbol":"_dispatch_mach_msg_async_reply_invoke","symbolLocation":397,"imageIndex":9},{"imageOffset":36709,"symbol":"_dispatch_lane_serial_drain","symbolLocation":375,"imageIndex":9},{"imageOffset":40184,"symbol":"_dispatch_lane_invoke","symbolLocation":455,"imageIndex":9},{"imageOffset":84347,"symbol":"_dispatch_workloop_worker_thread","symbolLocation":779,"imageIndex":9},{"imageOffset":12240,"symbol":"_pthread_wqthread","symbolLocation":326,"imageIndex":5},{"imageOffset":8023,"symbol":"start_wqthread","symbolLocation":15,"imageIndex":5}]}], "usedImages" : [ { "size" : 0, "source" : "A", "base" : 0, "uuid" : "00000000-0000-0000-0000-000000000000" }, { "source" : "P", "arch" : "x86_64", "base" : 4809781248, "size" : 102400, "uuid" : "e2edb2f5-e4de-3c55-b5d7-6f9349d6c34d", "path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/usr\/lib\/system\/libsystem_trace.dylib", "name" : "libsystem_trace.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 4588933120, "CFBundleShortVersionString" : "6.9", "CFBundleIdentifier" : "com.apple.CoreFoundation", "size" : 4218880, "uuid" : "d7b873d0-2d44-362d-a632-91b54d2dd8c2", "path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/System\/Library\/Frameworks\/CoreFoundation.framework\/CoreFoundation", "name" : "CoreFoundation", "CFBundleVersion" : "1863" }, { "source" : "P", "arch" : "x86_64", "base" : 4638973952, "CFBundleShortVersionString" : "6.9", "CFBundleIdentifier" : "com.apple.Foundation", "size" : 3100672, "uuid" : "9827fa7d-2500-32d7-aaaf-288e38b126ab", "path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/System\/Library\/Frameworks\/Foundation.framework\/Foundation", "name" : "Foundation", "CFBundleVersion" : "1863" }, { "source" : "P", "arch" : "x86_64", "base" : 4511948800, "size" : 65536, "uuid" : "c66d8418-40f8-3ae7-8bda-7918cb0b6ae4", "path" : "\/Users\/USER\/Library\/Developer\/CoreSimulator\/Devices\/02F1B274-3BDC-471F-9304-EC96459FB2BC\/data\/Containers\/Bundle\/Application\/8F088341-30E9-4168-81FF-61B555F0DF29\/IosApp1.app\/libSystem.Native.dylib", "name" : "libSystem.Native.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 4818571264, "size" : 49152, "uuid" : "bc574849-1aae-31e7-b350-916dda999d97", "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib", "name" : "libsystem_pthread.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 4522930176, "size" : 4947968, "uuid" : "5344b178-6c90-3cd7-b92c-8f228acb48d2", "path" : "\/Users\/USER\/Library\/Developer\/CoreSimulator\/Devices\/02F1B274-3BDC-471F-9304-EC96459FB2BC\/data\/Containers\/Bundle\/Application\/8F088341-30E9-4168-81FF-61B555F0DF29\/IosApp1.app\/libmonosgen-2.0.dylib", "name" : "libmonosgen-2.0.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 4817920000, "size" : 229376, "uuid" : "61711d11-e776-3bc3-b9a2-6f9f37cb8499", "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib", "name" : "libsystem_kernel.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 4986441728, "CFBundleShortVersionString" : "1.0", "CFBundleIdentifier" : "com.apple.UIKitCore", "size" : 25751552, "uuid" : "f710b655-42ee-3939-a3bd-6da0f3758758", "path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/System\/Library\/PrivateFrameworks\/UIKitCore.framework\/UIKitCore", "name" : "UIKitCore", "CFBundleVersion" : "5612" }, { "source" : "P", "arch" : "x86_64", "base" : 4792823808, "size" : 290816, "uuid" : "a1e15d82-e95a-30ec-832e-288d5d2c9a5f", "path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/usr\/lib\/system\/libdispatch.dylib", "name" : "libdispatch.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 4818817024, "size" : 212992, "uuid" : "a18dc746-2134-3b7b-9103-15acc4b258cc", "path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/usr\/lib\/system\/libxpc.dylib", "name" : "libxpc.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 4807544832, "size" : 208896, "uuid" : "791e787b-f11e-36d6-925b-5c10df76d693", "path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/usr\/lib\/libobjc.A.dylib", "name" : "libobjc.A.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 4516941824, "size" : 327680, "uuid" : "e3065f66-c845-3342-a987-aa5cc8da624a", "path" : "\/Users\/USER\/Library\/Developer\/CoreSimulator\/Devices\/02F1B274-3BDC-471F-9304-EC96459FB2BC\/data\/Containers\/Bundle\/Application\/8F088341-30E9-4168-81FF-61B555F0DF29\/IosApp1.app\/libxamarin-dotnet-debug.dylib", "name" : "libxamarin-dotnet-debug.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 4834471936, "CFBundleShortVersionString" : "765.10", "CFBundleIdentifier" : "com.apple.FrontBoardServices", "size" : 643072, "uuid" : "c6d4c356-5fae-3e2c-b71c-d3e0175ea504", "path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/System\/Library\/PrivateFrameworks\/FrontBoardServices.framework\/FrontBoardServices", "name" : "FrontBoardServices", "CFBundleVersion" : "765.10" }, { "source" : "P", "arch" : "x86_64", "base" : 4840001536, "CFBundleShortVersionString" : "1.0", "CFBundleIdentifier" : "com.apple.GraphicsServices", "size" : 36864, "uuid" : "d645c3c0-b4f8-31d0-bada-02aea61681d5", "path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/System\/Library\/PrivateFrameworks\/GraphicsServices.framework\/GraphicsServices", "name" : "GraphicsServices", "CFBundleVersion" : "1.0" }, { "source" : "P", "arch" : "x86_64", "base" : 4366348288, "CFBundleShortVersionString" : "1.0", "CFBundleIdentifier" : "com.companyname.IosApp1", "size" : 950272, "uuid" : "9ea51796-b474-309b-a99d-38a0614ca8df", "path" : "\/Users\/USER\/Library\/Developer\/CoreSimulator\/Devices\/02F1B274-3BDC-471F-9304-EC96459FB2BC\/data\/Containers\/Bundle\/Application\/8F088341-30E9-4168-81FF-61B555F0DF29\/IosApp1.app\/IosApp1", "name" : "IosApp1", "CFBundleVersion" : "1.0" }, { "source" : "P", "arch" : "x86_64", "base" : 4512854016, "size" : 319488, "uuid" : "7276a69b-e3b9-3f23-957f-061350a501b4", "path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/usr\/lib\/dyld_sim", "name" : "dyld_sim" }, { "source" : "P", "arch" : "x86_64", "base" : 8666533888, "size" : 442368, "uuid" : "b70ce1ec-b902-3852-8268-05de00bfa8d5", "path" : "\/usr\/lib\/dyld", "name" : "dyld" } ], "vmSummary" : "ReadOnly portion of Libraries: Total=1.2G resident=0K(0%) swapped_out_or_unallocated=1.2G(100%)\nWritable regions: Total=1.3G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.3G(100%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nActivity Tracing 256K 1 \nColorSync 24K 4 \nFoundation 16K 1 \nKernel Alloc Once 8K 1 \nMALLOC 268.2M 42 \nMALLOC guard page 48K 10 \nMALLOC_MEDIUM (reserved) 464.0M 4 reserved VM address space (unallocated)\nMALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated)\nRosetta Arena 4096K 2 \nRosetta Generic 9088K 2269 \nRosetta IndirectBranch 1024K 1 \nRosetta JIT 128.0M 1 \nRosetta Return Stack 180K 18 \nRosetta Thread Context 180K 18 \nSTACK GUARD 16K 4 \nStack 13.6M 9 \nStack Guard 56.0M 5 \nVM_ALLOCATE 33.0M 41 \nVM_ALLOCATE (reserved) 20K 2 reserved VM address space (unallocated)\n__DATA 31.7M 946 \n__DATA_CONST 66.2M 742 \n__DATA_DIRTY 84K 11 \n__FONT_DATA 4K 1 \n__LINKEDIT 487.2M 762 \n__TEXT 695.3M 760 \n__UNICODE 592K 1 \ndyld private memory 2048K 2 \nmapped file 6.1G 48 \nshared memory 16K 1 \n=========== ======= ======= \nTOTAL 8.7G 5708 \nTOTAL, minus reserved VM space 7.9G 5708 \n", "legacyInfo" : { "threadTriggered" : { "name" : "tid_103", "queue" : "com.apple.main-thread" } }, "trialInfo" : { "rollouts" : [ { "rolloutId" : "5ffde50ce2aacd000d47a95f", "factorPackIds" : { }, "deploymentId" : 240000158 }, { "rolloutId" : "607844aa04477260f58a8077", "factorPackIds" : { "SIRI_MORPHUN_ASSETS" : "6103050cbfe6dc472e1c982a" }, "deploymentId" : 240000066 } ], "experiments" : [ ] }, "reportNotes" : [ "dyld_process_snapshot_get_shared_cache failed" ] } Model: MacBookPro18,1, BootROM 7459.121.3, proc 10:8:2 processors, 32 GB, SMC Graphics: Apple M1 Pro, Apple M1 Pro, Built-In Display: Color LCD, 3456 x 2234 Retina, Main, MirrorOff, Online Display: LG Ultra HD, 3840 x 2160 (2160p/4K UHD 1 - Ultra High Definition), MirrorOff, Online Memory Module: LPDDR5 AirPort: Wi-Fi, wl0: Apr 6 2022 05:55:54 version 20.90.45.0.8.7.118 FWID 01-e7138ff2 Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports Network Service: Wi-Fi, AirPort, en0 USB Device: USB31Bus USB Device: YubiKey OTP+FIDO+CCID USB Device: USB31Bus USB Device: USB31Bus Thunderbolt Bus: MacBook Pro, Apple Inc. Thunderbolt Bus: MacBook Pro, Apple Inc. Thunderbolt Bus: MacBook Pro, Apple Inc. ```

I think this is similar to the issues reported in #12040 and #14796, but I'm not certain. Is there any workaround? If not, I don't think should wait for .NET 7.

rolfbjarne commented 2 years ago

A potential workaround would be to add event handlers to the Runtime.MarshalManagedException and Runtime.MarshalObjectiveCException events and handle those as you handle AppDomain.CurrentDomain.UnhandledException.

Ref: https://docs.microsoft.com/en-us/xamarin/ios/platform/exception-marshaling#events

mattjohnsonpint commented 2 years ago

Thanks. After testing with those, I find that by default the same thing happens there as well. MarshalManagedException fires thousands of times. MarshalObjectiveCException never fires.

However, if I set the ExceptionMode to UnwindNativeCode in MarshalManagedException, then things start looking more like I expect them to.

AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
{
    Console.WriteLine("In UnhandledException Handler");
};

AppDomain.CurrentDomain.FirstChanceException += (sender, args) =>
{
    Console.WriteLine("In FirstChanceException Handler");
};

ObjCRuntime.Runtime.MarshalManagedException += (sender, args) =>
{
    Console.WriteLine("In MarshalManagedException Handler");

    args.ExceptionMode = ObjCRuntime.MarshalManagedExceptionMode.UnwindNativeCode;
};

ObjCRuntime.Runtime.MarshalObjectiveCException += (sender, args) =>
{
    Console.WriteLine("In MarshalObjectiveCException Handler");
};

throw new Exception("Test Exception");

My debug output now includes the following:

  2022-06-13 10:31:30.161041-0700 IosApp1[48797:2241605] In FirstChanceException Handler
  2022-06-13 10:31:30.163774-0700 IosApp1[48797:2241605] In MarshalManagedException Handler
  2022-06-13 10:31:30.166228-0700 IosApp1[48797:2241605] In FirstChanceException Handler
  2022-06-13 10:31:30.166646-0700 IosApp1[48797:2241605] In FirstChanceException Handler
  2022-06-13 10:31:30.167401-0700 IosApp1[48797:2241605] In UnhandledException Handler
  2022-06-13 10:31:30.226152-0700 IosApp1[48797:2241605] Unhandled managed exception: Test Exception (System.Exception)
     at IosApp1.AppDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions) in /Users/matt/Code/IosApp1/AppDelegate.cs:line 51

So it seems I can workaround the issue for now by using MarshalManagedException to change the exception mode to UnwindNativeCode, and then just using AppDomain.CurrentDomain.UnhandledException as normal. Does that sound right to you?

I am a bit confused why this works though. The doc you pointed at says:

  • Default: The default varies by platform. It's always ThrowObjectiveCException in .NET. For legacy Xamarin projects, it's ThrowObjectiveCException if the GC is in cooperative mode (watchOS), and UnwindNativeCode otherwise (iOS / watchOS / macOS). The default may change in the future.
  • UnwindNativeCode: This is the previous (undefined) behavior. This isn't available when using the GC in cooperative mode (which is the only option on watchOS; thus, this isn't a valid option on watchOS), nor when using CoreCLR, but it's the default option for all other platforms in legacy Xamarin projects.

So, why does setting UnwindNativeCode in an iOS project change anything, when the docs say that's the default mode for iOS? Could it be because I'm running in a simulator?

rolfbjarne commented 2 years ago

So, why does setting UnwindNativeCode in an iOS project change anything, when the docs say that's the default mode for iOS? Could it be because I'm running in a simulator?

We changed the default in .NET, and that page hasn't been updated yet:

https://github.com/xamarin/xamarin-macios/wiki/.NET-release-notes-Xcode-13.3#exception-marshalling-is-enabled-by-default

rolfbjarne commented 2 years ago

So it seems I can workaround the issue for now by using MarshalManagedException to change the exception mode to UnwindNativeCode, and then just using AppDomain.CurrentDomain.UnhandledException as normal. Does that sound right to you?

Yes, I think that should work fine.

mattjohnsonpint commented 2 years ago

Thanks!

jwosty commented 1 year ago

Confirming that the same problem exists for macOS applications, and that setting the exception mode to Unwind doesn't seem to make AppDomain.CurrentDomain.UnhandledException trigger. Currently using the workaround described by @rolfbjarne (just putting my custom exception logging code in MarshalManagedException and MarshalObjectiveCException).

tipa commented 1 year ago

I think the comments in this file also have to be updated to reflect what is now the default: https://github.com/xamarin/xamarin-macios/blob/main/src/ObjCRuntime/ExceptionMode.cs

mlancione commented 1 year ago

A potential workaround would be to add event handlers to the Runtime.MarshalManagedException and Runtime.MarshalObjectiveCException events and handle those as you handle AppDomain.CurrentDomain.UnhandledException.

Ref: https://docs.microsoft.com/en-us/xamarin/ios/platform/exception-marshaling#events

@rolfbjarne Does this workaround apply to Xamarin.iOS as well? It seems that Runtime.MarshalManagedException, Runtime.MarshalObjectiveCException and AppDomain.CurrentDomain.UnhandledException don't trigger at all in Release mode in Xamarin.iOS unless --interpreter=all is set. Unfortunately, enabling the interpreter in Xamarin.iOS for us is a huge performance hit.

rolfbjarne commented 1 year ago

A potential workaround would be to add event handlers to the Runtime.MarshalManagedException and Runtime.MarshalObjectiveCException events and handle those as you handle AppDomain.CurrentDomain.UnhandledException. Ref: docs.microsoft.com/en-us/xamarin/ios/platform/exception-marshaling#events

@rolfbjarne Does this workaround apply to Xamarin.iOS as well? It seems that Runtime.MarshalManagedException, Runtime.MarshalObjectiveCException and AppDomain.CurrentDomain.UnhandledException don't trigger at all in Release mode in Xamarin.iOS unless --interpreter=all is set. Unfortunately, enabling the interpreter in Xamarin.iOS for us is a huge performance hit.

Yes, but you must explicitly enable exception marshalling (we turned it on by default in .NET).

You can do that by adding this to the additional mtouch arguments in the project's iOS Build options (this is the MtouchExtraArgs property in the csproj).

--marshal-managed-exceptions=throwobjectivecexception --marshal-objectivec-exceptions=throwmanagedexception
rohanp-91 commented 1 year ago

Has this issue been resolved in .NET 7?

Confirming that the same problem exists for macOS applications, and that setting the exception mode to Unwind doesn't seem to make AppDomain.CurrentDomain.UnhandledException trigger. Currently using the workaround described by @rolfbjarne (just putting my custom exception logging code in MarshalManagedException and MarshalObjectiveCException).

For a .NET 7 macOS application, it looks like the AppDomain.UnhandledException is not triggered at all. I tested it by throwing a managed exception on the main thread. I can see that the Runtime.MarshalManagedException is fired, but then setting the ExceptionMode to UnwindNativeCode doesn't fire the UnhandledException either, it just crashes the app.

rolfbjarne commented 1 year ago

Has this issue been resolved in .NET 7?

No, it's not been fixed yet.

rolfbjarne commented 3 months ago

A few updates:

The log shows that the FirstChanceException handler fires over 1000 times

This has been fixed (9b8869b2210068bdfce38e9a2f88ed40e69fed2d).

In my test case, FirstChanceException is printed four times:

  1. The initial throw statement.
  2. We catch this initial exception on the managed-to-native boundary, and convert it into an Objective-C exception. During this conversion process, there are 2 exceptions internal to the runtime (trying to look up resource assemblies that don't exist - these exceptions are benign and would go unnoticed except in FirstChanceException).
  3. We've thrown the Objective-C exception, but there are no Objective-C exception handlers. The code flow goes into the unhandled Objective-C exception handler - where we convert the Objective-C exception to a managed exception and throw that.

We can probably fix the fourth, but we likely won't be able to fix the second and third.

The UnhandledException handler never fires.

This is not fixed. In fact there doesn't seem to be a way for us to call this handler, the managed runtime does it automatically during exception handler. Unfortunately we're somewhat exceptional, so the existing logic in the managed runtime doesn't work for us.

rolfbjarne commented 3 months ago

I've filed https://github.com/dotnet/runtime/issues/102730 to see if we can find a way to raise the UnhandledException event.

rolfbjarne commented 2 days ago

The problem with the UnhandledException event not being raised has been fixed when using MonoVM (this means on iOS, Mac Catalyst and tvOS, as long as you're not using NativeAOT). It's still a problem when using CoreCLR (on macOS or when using NativeAOT).