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.49k stars 515 forks source link

Crash in production code and don't know what's going on #13055

Closed GuidoNeele closed 2 years ago

GuidoNeele commented 3 years ago

Steps to Reproduce

  1. Can't reproduce the error while debugging.

Expected Behavior

App shouldn't crash

Actual Behavior

App crashes during background fetch

Crash report

Anybody know what's going on with this Xamarin Forms iOS app crash? App crashes during or while starting background fetch. Don't see any recognizable methods of our app that can lead me in the right direction. The app crashes on several devices (iPhones and iPads). Can't reproduce the error since the app doesn't crash while the debugger is attached. Tried running the app while sending the simulate background fetch request and also started the app with the background fetch profile directly, in both cases the app does what it needs to do without crashing.

Incident Identifier: 9FD6FBB7-5AEC-43C4-8D46-D8DB2358F540
Hardware Model:      iPhone10,5
Process:             MyApp.iOS [76395]
Path:                /private/var/containers/Bundle/Application/D7FCE01D-51CD-4ADF-AF35-E9213110401A/MyApp.iOS.app/MyApp.iOS
Identifier:          com.company.product
Version:             3.6.22 (3.6.22)
AppStoreTools:       13A227
AppVariant:          1:iPhone10,5:14
Beta:                YES
Code Type:           ARM-64 (Native)
Role:                Non UI
Parent Process:      launchd [1]
Coalition:           com.company.product [3668]

Date/Time:           2021-10-17 06:00:12.6268 +0200
Launch Time:         2021-10-17 06:00:10.4291 +0200
OS Version:          iPhone OS 14.7.1 (18G82)
Release Type:        User
Baseband Version:    4.04.00
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib    0x00000001cb2b27b0 __pthread_kill + 8
1   libsystem_pthread.dylib   0x00000001e79809c0 pthread_kill + 208
2   libsystem_c.dylib         0x00000001a8083a38 abort + 116
3   MyApp.iOS                 0x0000000104e98a74 xamarin_unhandled_exception_handler (runtime.m:1100)
4   MyApp.iOS                 0x0000000104d5f500 mono_invoke_unhandled_exception_hook (exception.c:1265)
5   MyApp.iOS                 0x0000000104cf46c8 mono_handle_exception_internal (mini-exceptions.c:2791)
6   MyApp.iOS                 0x0000000104cf309c mono_handle_exception (mini-exceptions.c:3116)
7   MyApp.iOS                 0x0000000104ce8e18 mono_arm_throw_exception (exceptions-arm64.c:401)
8   MyApp.iOS                 0x00000001013ab86c throw_exception + 168
9   MyApp.iOS                 0x00000001010caa2c System_Runtime_ExceptionServices_ExceptionDispatchInfo_Throw + 40
10  MyApp.iOS                 0x00000001010d2254 System_Runtime_CompilerServices_AsyncMethodBuilderCore__c__ThrowAsyncb__7_0_object + 80
11  MyApp.iOS                 0x000000010237d47c Foundation_NSAsyncSynchronizationContextDispatcher_Apply (NSAction.cs:178)
12  MyApp.iOS                 0x0000000101365d20 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 268
13  MyApp.iOS                 0x0000000104d06410 mono_jit_runtime_invoke (mini-runtime.c:3190)
14  MyApp.iOS                 0x0000000104dbff9c mono_runtime_invoke_checked (object.c:3052)
15  MyApp.iOS                 0x0000000104dc37dc mono_runtime_invoke (object.c:3107)
16  MyApp.iOS                 0x0000000100ee6b10 native_to_managed_trampoline_11(objc_object*, objc_selector*, _MonoMethod**, unsigned int) (registrar.m:684)
17  MyApp.iOS                 0x0000000100eec420 -[__MonoMac_NSAsyncSynchronizationContextDispatcher xamarinApplySelector] (registrar.m:10893)
18  Foundation                0x00000001a077eee8 __NSThreadPerformPerform + 180
19  CoreFoundation            0x000000019f3cb8a8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 20
20  CoreFoundation            0x000000019f3cb7a8 __CFRunLoopDoSource0 + 200
21  CoreFoundation            0x000000019f3cab60 __CFRunLoopDoSources0 + 352
22  CoreFoundation            0x000000019f3c5018 __CFRunLoopRun + 764
23  CoreFoundation            0x000000019f3c47d0 CFRunLoopRunSpecific + 568
24  GraphicsServices          0x00000001b5b06570 GSEventRunModal + 156
25  UIKitCore                 0x00000001a1cf12d0 -[UIApplication _run] + 1048
26  UIKitCore                 0x00000001a1cf684c UIApplicationMain + 160
27  MyApp.iOS                 0x00000001023f4ba8 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 340
28  MyApp.iOS                 0x0000000102321530 UIKit_UIApplication_Main_string___System_Type_System_Type (UIApplication.cs:79)
29  MyApp.iOS                 0x0000000100f2dd84 MyApp_iOS_Application_Main_string__ (<unknown>:1)
30  MyApp.iOS                 0x0000000101365d20 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 268
31  MyApp.iOS                 0x0000000104d06410 mono_jit_runtime_invoke (mini-runtime.c:3190)
32  MyApp.iOS                 0x0000000104dbff9c mono_runtime_invoke_checked (object.c:3052)
33  MyApp.iOS                 0x0000000104dc6250 mono_runtime_exec_main_checked (object.c:0)
34  MyApp.iOS                 0x0000000104ce4820 mono_jit_exec (driver.c:1383)
35  MyApp.iOS                 0x0000000104ea1298 xamarin_main (monotouch-main.m:485)
36  MyApp.iOS                 0x0000000100f2dce8 main (main.m:304)
37  libdyld.dylib             0x000000019f0a3140 start + 0

Thread 1:
0   libsystem_pthread.dylib         0x00000001e7984864 start_wqthread + 0

Thread 2 name:
Thread 2:
0   libsystem_kernel.dylib          0x00000001cb2b2580 __psynch_cvwait + 8
1   libsystem_pthread.dylib         0x00000001e797cd78 _pthread_cond_wait$VARIANT$armv81 + 1236 (pthread_cond.c:636)
2   ....MyApp.iOS   0x0000000108657168 thread_func + 66974056 (sgen-thread-pool.c:196)
3   libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
4   libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 3 name:
Thread 3:
0   libsystem_kernel.dylib          0x00000001cb28e944 semaphore_wait_trap + 8
1   ....MyApp.iOS   0x0000000108556908 finalizer_thread + 65923336 (gc.c:965)
2   ....MyApp.iOS   0x0000000108601aa0 start_wrapper_internal + 66624160 (threads.c:1289)
3   ....MyApp.iOS   0x0000000108601924 start_wrapper + 66623780 (threads.c:1310)
4   libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
5   libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 4:
0   libsystem_pthread.dylib         0x00000001e7984864 start_wqthread + 0

Thread 5 name:
Thread 5:
0   libsystem_pthread.dylib         0x00000001e7984864 start_wqthread + 0

Thread 6 name:
Thread 6:
0   libsystem_kernel.dylib          0x00000001cb28e908 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x00000001cb28dd0c mach_msg + 72 (mach_msg.c:103)
2   CoreFoundation                  0x000000019f3cadb8 __CFRunLoopServiceMachPort + 368 (CFRunLoop.c:2641)
3   CoreFoundation                  0x000000019f3c51b8 __CFRunLoopRun + 1184 (CFRunLoop.c:2974)
4   CoreFoundation                  0x000000019f3c47d0 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3242)
5   Foundation                      0x00000001a0621e64 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 228 (NSRunLoop.m:377)
6   Foundation                      0x00000001a0621d44 -[NSRunLoop(NSRunLoop) runUntilDate:] + 88 (NSRunLoop.m:424)
7   UIKitCore                       0x00000001a1d9de10 -[UIEventFetcher threadMain] + 504 (UIEventFetcher.m:929)
8   Foundation                      0x00000001a077ed90 __NSThread__start__ + 848 (NSThread.m:724)
9   libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
10  libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 7 name:
Thread 7:
0   libsystem_pthread.dylib         0x00000001e7984864 start_wqthread + 0

Thread 8:
0   libsystem_pthread.dylib         0x00000001e7984864 start_wqthread + 0

Thread 9 name:
Thread 9:
0   libsystem_kernel.dylib          0x00000001cb2b2580 __psynch_cvwait + 8
1   libsystem_pthread.dylib         0x00000001e797cd78 _pthread_cond_wait$VARIANT$armv81 + 1236 (pthread_cond.c:636)
2   ....MyApp.iOS   0x00000001086666e4 mono_os_cond_timedwait + 67036900 (mono-os-mutex.c:75)
3   ....MyApp.iOS   0x000000010860d1c8 mono_w32handle_timedwait_signal_handle + 66671048 (w32handle.c:767)
4   ....MyApp.iOS   0x000000010860d0a0 mono_w32handle_wait_one + 66670752 (w32handle.c:895)
5   ....MyApp.iOS   0x000000010860d2c4 mono_w32handle_wait_multiple + 66671300 (w32handle.c:1002)
6   ....MyApp.iOS   0x00000001085fbfcc ves_icall_System_Threading_WaitHandle_Wait_internal + 66600908 (threads.c:2314)
7   ....MyApp.iOS   0x0000000108577fc0 ves_icall_System_Threading_WaitHandle_Wait_internal_raw + 66060224 (icall-def.h:1100)
8   ....MyApp.iOS   0x0000000104848a28 wrapper_managed_to_native_System_Threading_WaitHandle_Wait_internal_intptr__int_bool_int + 120
9   ....MyApp.iOS   0x0000000104848594 System_Threading_WaitHandle_WaitOneNative_System_Runtime_InteropServices_SafeHandle_uint_bool_bool + 260
10  ....MyApp.iOS   0x000000010484808c System_Threading_WaitHandle_InternalWaitOne_System_Runtime_InteropServices_SafeHandle_long_bool_bool + 60
11  ....MyApp.iOS   0x000000010484803c System_Threading_WaitHandle_WaitOne_long_bool + 60
12  ....MyApp.iOS   0x0000000104847e5c System_Threading_WaitHandle_WaitOne_int_bool + 60
13  ....MyApp.iOS   0x0000000104847fa8 System_Threading_WaitHandle_WaitOne_int + 40
14  ....MyApp.iOS   0x000000010484b5d4 System_Threading_Timer_Scheduler_SchedulerThread + 212
15  ....MyApp.iOS   0x0000000104841edc System_Threading_ThreadHelper_ThreadStart_Context_object + 188
16  ....MyApp.iOS   0x000000010483f54c System_Threading_ExecutionContext_RunInternal_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 428
17  ....MyApp.iOS   0x000000010483f34c System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 44
18  ....MyApp.iOS   0x000000010483f2d0 System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object + 80
19  ....MyApp.iOS   0x0000000104842044 System_Threading_ThreadHelper_ThreadStart + 52
20  ....MyApp.iOS   0x0000000104b59d20 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 272
21  ....MyApp.iOS   0x00000001084fa410 mono_jit_runtime_invoke + 65545232 (mini-runtime.c:3191)
22  ....MyApp.iOS   0x00000001085b3f9c mono_runtime_invoke_checked + 66305948 (object.c:3220)
23  ....MyApp.iOS   0x00000001085b98e4 mono_runtime_delegate_try_invoke + 66328804 (object.c:4437)
24  ....MyApp.iOS   0x0000000108601b98 start_wrapper_internal + 66624408 (threads.c:1258)
25  ....MyApp.iOS   0x0000000108601924 start_wrapper + 66623780 (threads.c:1310)
26  libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
27  libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 10 name:
Thread 10:
0   libsystem_kernel.dylib          0x00000001cb2b2580 __psynch_cvwait + 8
1   libsystem_pthread.dylib         0x00000001e797cd78 _pthread_cond_wait$VARIANT$armv81 + 1236 (pthread_cond.c:636)
2   ....MyApp.iOS   0x00000001086666e4 mono_os_cond_timedwait + 67036900 (mono-os-mutex.c:75)
3   ....MyApp.iOS   0x000000010866f44c mono_thread_info_sleep + 67073100 (mono-threads.c:1672)
4   ....MyApp.iOS   0x00000001085f5c4c monitor_thread + 66575436 (threadpool-worker-default.c:728)
5   ....MyApp.iOS   0x0000000108601aa0 start_wrapper_internal + 66624160 (threads.c:1289)
6   ....MyApp.iOS   0x0000000108601924 start_wrapper + 66623780 (threads.c:1310)
7   libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
8   libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 11 name:
Thread 11:
0   libsystem_kernel.dylib          0x00000001cb28e95c semaphore_timedwait_trap + 8
1   ....MyApp.iOS   0x00000001085f6504 worker_thread + 66577668 (threadpool-worker-default.c:490)
2   ....MyApp.iOS   0x0000000108601aa0 start_wrapper_internal + 66624160 (threads.c:1289)
3   ....MyApp.iOS   0x0000000108601924 start_wrapper + 66623780 (threads.c:1310)
4   libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
5   libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 12 name:
Thread 12:
0   libsystem_kernel.dylib          0x00000001cb28e95c semaphore_timedwait_trap + 8
1   ....MyApp.iOS   0x00000001085f6504 worker_thread + 66577668 (threadpool-worker-default.c:490)
2   ....MyApp.iOS   0x0000000108601aa0 start_wrapper_internal + 66624160 (threads.c:1289)
3   ....MyApp.iOS   0x0000000108601924 start_wrapper + 66623780 (threads.c:1310)
4   libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
5   libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 13:
0   libsystem_kernel.dylib          0x00000001cb2b2b54 __semwait_signal + 8
1   libsystem_c.dylib               0x00000001a8080ab4 nanosleep + 212 (nanosleep.c:104)
2   ....MyApp.iOS   0x000000010888ce78 realm::millisleep+ 69291640 (unsigned long) + 80
3   ....MyApp.iOS   0x000000010887a0d4 realm::util::reclaimer_loop+ 69214420 () + 36
4   ....MyApp.iOS   0x000000010887c9e8 void* std::__1::__thread_proxy<std::__1::tuple<void (*)()> >+ 69224936 (void*) + 92
5   libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
6   libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 14 name:
Thread 14:
0   ....MyApp.iOS   0x000000010865fb94 mono_conc_hashtable_lookup + 67009428 (mono-conc-hashtable.c:227)
1   ....MyApp.iOS   0x000000010865fb1c mono_conc_hashtable_lookup + 67009308 (mono-conc-hashtable.c:206)
2   ....MyApp.iOS   0x000000010859efe8 mono_metadata_lookup_generic_class + 66220008 (metadata.c:3567)
3   ....MyApp.iOS   0x0000000108539864 inflate_generic_type + 65804388 (class.c:846)
4   ....MyApp.iOS   0x0000000108539cbc mono_class_inflate_generic_type_checked + 65805500 (class.c:1023)
5   ....MyApp.iOS   0x00000001084d483c decode_klass_ref + 65390652 (aot-runtime.c:528)
6   ....MyApp.iOS   0x00000001084d4648 decode_klass_ref + 65390152 (aot-runtime.c:626)
7   ....MyApp.iOS   0x00000001084d2b6c decode_method_ref_with_target + 65383276 (aot-runtime.c:1341)
8   ....MyApp.iOS   0x00000001084d5f40 find_aot_method_in_amodule + 65396544 (aot-runtime.c:4427)
9   ....MyApp.iOS   0x00000001084cd060 find_aot_method + 65359968 (aot-runtime.c:4555)
10  ....MyApp.iOS   0x00000001084ccf18 mono_aot_find_method_index + 65359640 (aot-runtime.c:4570)
11  ....MyApp.iOS   0x00000001084e6020 ves_icall_get_trace + 65462304 (mini-exceptions.c:0)
12  ....MyApp.iOS   0x000000010498a960 wrapper_managed_to_native_System_Diagnostics_StackTrace_get_trace_System_Exception_int_bool + 112
13  ....MyApp.iOS   0x000000010498aa4c System_Diagnostics_StackTrace__ctor_System_Exception_int_bool + 60
14  ....MyApp.iOS   0x00000001048be8d4 System_Runtime_ExceptionServices_ExceptionDispatchInfo__ctor_System_Exception + 212
15  ....MyApp.iOS   0x00000001048be994 System_Runtime_ExceptionServices_ExceptionDispatchInfo_Capture_System_Exception + 52
16  ....MyApp.iOS   0x0000000104865f8c System_Threading_Tasks_TaskExceptionHolder_AddFaultException_object + 236
17  ....MyApp.iOS   0x0000000104865d58 System_Threading_Tasks_TaskExceptionHolder_Add_object_bool + 56
18  ....MyApp.iOS   0x000000010485c2ac System_Threading_Tasks_Task_AddException_object_bool + 364
19  ....MyApp.iOS   0x000000010485c130 System_Threading_Tasks_Task_AddException_object + 32
20  ....MyApp.iOS   0x000000010485a2c4 System_Threading_Tasks_Task_TrySetException_object + 84
21  ....MyApp.iOS   0x00000001048c4780 System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_TResult_REF_SetException_System_Exception + 144
22  ....MyApp.iOS   0x0000000106344a8c Shiny_Infrastructure_FileSystemRepositoryImpl__GetAlld__7_1_T_REF_MoveNext + 30198412 (FileSystemRepositoryImpl.cs:61)
23  ....MyApp.iOS   0x00000001048c5fac System_Runtime_CompilerServices_AsyncMethodBuilderCore_MoveNextRunner_InvokeMoveNext_object + 156
24  ....MyApp.iOS   0x000000010483f54c System_Threading_ExecutionContext_RunInternal_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 428
25  ....MyApp.iOS   0x000000010483f34c System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 44
26  ....MyApp.iOS   0x00000001048c5e68 System_Runtime_CompilerServices_AsyncMethodBuilderCore_MoveNextRunner_Run + 200
27  ....MyApp.iOS   0x0000000104865990 System_Threading_Tasks_AwaitTaskContinuation_RunOrScheduleAction_System_Action_bool_System_Threading_Tasks_Task_ + 112
28  ....MyApp.iOS   0x000000010485e648 System_Threading_Tasks_Task_FinishContinuations + 392
29  ....MyApp.iOS   0x000000010485cbd0 System_Threading_Tasks_Task_FinishStageThree + 160
30  ....MyApp.iOS   0x000000010485cb10 System_Threading_Tasks_Task_FinishStageTwo + 464
31  ....MyApp.iOS   0x000000010485c854 System_Threading_Tasks_Task_Finish_bool + 164
32  ....MyApp.iOS   0x0000000104861a9c System_Threading_Tasks_Task_ExecuteWithThreadLocal_System_Threading_Tasks_Task_ + 332
33  ....MyApp.iOS   0x000000010485d290 System_Threading_Tasks_Task_ExecuteEntry_bool + 272
34  ....MyApp.iOS   0x000000010485d168 System_Threading_Tasks_Task_System_Threading_IThreadPoolWorkItem_ExecuteWorkItem + 24
35  ....MyApp.iOS   0x0000000104844aa8 System_Threading_ThreadPoolWorkQueue_Dispatch + 488
36  ....MyApp.iOS   0x0000000105ad7fd0 ObjCRuntime_Runtime_ThreadPoolDispatcher_System_Func_1_bool + 21364688 (Runtime.cs:330)
37  ....MyApp.iOS   0x0000000104846b68 System_Threading__ThreadPoolWaitCallback_PerformWaitCallback + 136
38  ....MyApp.iOS   0x0000000104b59d20 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 272
39  ....MyApp.iOS   0x00000001084fa410 mono_jit_runtime_invoke + 65545232 (mini-runtime.c:3191)
40  ....MyApp.iOS   0x00000001085b5888 mono_runtime_try_invoke + 66312328 (object.c:3161)
41  ....MyApp.iOS   0x00000001085f8a98 worker_callback + 66587288 (threadpool.c:386)
42  ....MyApp.iOS   0x00000001085f630c worker_thread + 66577164 (threadpool-worker-default.c:502)
43  ....MyApp.iOS   0x0000000108601aa0 start_wrapper_internal + 66624160 (threads.c:1289)
44  ....MyApp.iOS   0x0000000108601924 start_wrapper + 66623780 (threads.c:1310)
45  libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
46  libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 15 name:
Thread 15:
0   libsystem_kernel.dylib          0x00000001cb2b4318 kevent + 8
1   ....MyApp.iOS   0x00000001086cac0c realm::_impl::ExternalCommitHelper::listen+ 67447820 () + 212
2   ....MyApp.iOS   0x00000001086cae3c std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator()+ 67448380 () + 28
3   ....MyApp.iOS   0x00000001086cadc4 std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::__execute+ 67448260 () + 28
4   ....MyApp.iOS   0x00000001086caf74 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >+ 67448692 (void*) + 64
5   libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
6   libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 16 name:
Thread 16:
0   libsystem_kernel.dylib          0x00000001cb28e95c semaphore_timedwait_trap + 8
1   ....MyApp.iOS   0x00000001085f6504 worker_thread + 66577668 (threadpool-worker-default.c:490)
2   ....MyApp.iOS   0x0000000108601aa0 start_wrapper_internal + 66624160 (threads.c:1289)
3   ....MyApp.iOS   0x0000000108601924 start_wrapper + 66623780 (threads.c:1310)
4   libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
5   libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 17 name:
Thread 17:
0   libsystem_kernel.dylib          0x00000001cb28e95c semaphore_timedwait_trap + 8
1   ....MyApp.iOS   0x00000001085f6504 worker_thread + 66577668 (threadpool-worker-default.c:490)
2   ....MyApp.iOS   0x0000000108601aa0 start_wrapper_internal + 66624160 (threads.c:1289)
3   ....MyApp.iOS   0x0000000108601924 start_wrapper + 66623780 (threads.c:1310)
4   libsystem_pthread.dylib         0x00000001e797fc74 _pthread_start + 288 (pthread.c:887)
5   libsystem_pthread.dylib         0x00000001e7984878 thread_start + 8

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000009   x5: 0x0000000112f05e00   x6: 0x0000000000001000   x7: 0x0000000000001300
    x8: 0x00000001095e7880   x9: 0xabec84f1574389d1  x10: 0x000000000000055f  x11: 0x0000000000000000
   x12: 0x00000001123f0800  x13: 0x000000010f3fce53  x14: 0x00000000000000e0  x15: 0x0000000080000000
   x16: 0x0000000000000148  x17: 0x0000000000007981  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x0000000000000103  x21: 0x00000001095e7960  x22: 0x0000000000000000  x23: 0x000000010a020600
   x24: 0x000000010f3fce50  x25: 0x000000016b7851b0  x26: 0x0000000000000002  x27: 0x0000000108ee8c80
   x28: 0x0000000000ffffff   fp: 0x000000016b7843b0   lr: 0x00000001e79809c0
    sp: 0x000000016b784390   pc: 0x00000001cb2b27b0 cpsr: 0x40000000
   esr: 0x56000080  Address size fault

Binary Images:
0x104678000 - 0x108b9ffff MyApp.iOS arm64  <bc1f3afa207d3092a54826be3929103b> /var/containers/Bundle/Application/D7FCE01D-51CD-4ADF-AF35-E9213110401A/MyApp.iOS.app/MyApp.iOS
0x109540000 - 0x1095abfff dyld arm64  <370cf6c9131737c2adb725d1384b9019> /usr/lib/dyld
0x10962c000 - 0x109aa7fff libSkiaSharp arm64  <a7293ebcef0a3c2caf5cab570e783fde> /var/containers/Bundle/Application/D7FCE01D-51CD-4ADF-AF35-E9213110401A/MyApp.iOS.app/Frameworks/libSkiaSharp.framework/libSkiaSharp
...
EOF

The background fetch is handled by Shiny (https://github.com/shinyorg/shiny). 9 jobs are started in sequence they all inherit from a BaseSyncJob that looks like this.

public abstract class BaseSyncJob : IJob
  {
    private readonly int syncIntervalInMinutes;
    private readonly bool isOrganisationRequired;

    protected readonly IBackgroundManager backgroundManager;
    protected readonly INotificationManager notificationManager;
    protected readonly ISessionManager sessionManager;
    protected readonly ISyncService syncService;

    /// <summary>
    /// Initializes a new instance of the <see cref="BaseSyncJob"/> class.
    ///
    /// Defaults: Runs every 24 hours and an organisation must be set
    /// </summary>
    /// <param name="syncService"></param>
    protected BaseSyncJob(ISyncService syncService)
      : this(syncService, 1440, true)
    {
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="BaseSyncJob"/> class.
    /// </summary>
    /// <param name="syncService"></param>
    /// <param name="syncIntervalInMinutes">Amount of minutes that must have passed since last sync</param>
    /// <param name="isOrganisationRequired">Indicates if an organisation is required for this sync to run successfully</param>
    protected BaseSyncJob(ISyncService syncService, int syncIntervalInMinutes, bool isOrganisationRequired)
    {
      this.syncService = syncService;

      this.sessionManager = ShinyHost.Resolve<ISessionManager>();
      this.notificationManager = ShinyHost.Resolve<INotificationManager>();
      this.backgroundManager = ShinyHost.Resolve<IBackgroundManager>();

      this.syncIntervalInMinutes = syncIntervalInMinutes;
      this.isOrganisationRequired = isOrganisationRequired;
    }

    public async Task Run(JobInfo jobInfo, CancellationToken cancellationToken)
    {
      try
      {
        var jobName = this.GetType().Name;

        Debug.WriteLine($"[BaseSyncJob.Run] Job {jobName} started!");

        AppService.TrackEvent($"Job {jobName} started!");

        // Check if user is logged in
        if (!await this.sessionManager.IsLoggedInAsync())
          return;

        Debug.WriteLine("[BaseSyncJob.Run] User is logged in");

#if !DEBUG
        if (jobInfo.LastRunUtc.HasValue && jobInfo.LastRunUtc.Value.AddMinutes(this.syncIntervalInMinutes) > DateTime.UtcNow) return;
#endif

        if (AppData.User == null)
        {
          Entities.User user = AppService.GetUser();

          if (user != null)
            AppData.User = user;
          else
            return;

          Debug.WriteLine("[BaseSyncJob.Run] AppData.User was set");
        }

        if (this.isOrganisationRequired && AppData.Organisation == null)
        {
          Entities.Organisation organisation = AppService.GetDefaultOrganisationByUser(AppData.User.Id);

          if (organisation != null)
            AppData.Organisation = organisation;
          else
            return;

          Debug.WriteLine("[BaseSyncJob.Run] AppData.Organisation was set");
        }

        // Run sync job
        await SyncDataAsync(cancellationToken);

        Debug.WriteLine("[BaseSyncJob.Run] OK sync completed!");

        return;
      }
      catch (Exception ex)
      {
        Debug.WriteLine(ex);

        var properties = new Dictionary<string, string>
        {
          { "Job", jobInfo.Identifier },
          { "In background", AppData.PlatformStatus == Enums.PlatformState.Background ? "True" : "False" }
        };

        AppService.TrackError(ex, properties);

        return;
      }
    }

    protected abstract Task SyncDataAsync(CancellationToken cancellationToken);
  }

We are using AppCenter but the crash doesn't get logged. AppCenter.Start() is one of the first things that gets called after starting the app.

chamons commented 3 years ago

So we are crashing due to an uncaught exception:

0   libsystem_kernel.dylib    0x00000001cb2b27b0 __pthread_kill + 8
1   libsystem_pthread.dylib   0x00000001e79809c0 pthread_kill + 208
2   libsystem_c.dylib         0x00000001a8083a38 abort + 116
3   MyApp.iOS                 0x0000000104e98a74 xamarin_unhandled_exception_handler (runtime.m:1100)
4   MyApp.iOS                 0x0000000104d5f500 mono_invoke_unhandled_exception_hook (exception.c:1265)
5   MyApp.iOS                 0x0000000104cf46c8 mono_handle_exception_internal (mini-exceptions.c:2791)
6   MyApp.iOS                 0x0000000104cf309c mono_handle_exception (mini-exceptions.c:3116)
7   MyApp.iOS                 0x0000000104ce8e18 mono_arm_throw_exception (exceptions-arm64.c:401)
8   MyApp.iOS                 0x00000001013ab86c throw_exception + 168
9   MyApp.iOS                 0x00000001010caa2c System_Runtime_ExceptionServices_ExceptionDispatchInfo_Throw + 40
10  MyApp.iOS                 0x00000001010d2254 System_Runtime_CompilerServices_AsyncMethodBuilderCore__c__ThrowAsyncb__7_0_object + 80

I question if your code is correct in reporting the exception and then swallowing. That means if you have corrupted state, your application will not crash. Reporting the error and then rethrowing is a more common pattern.

If you rethrow, it might crash closer to the source of the crash and provide more info.

Another option is to try to get the associated logs. Do you see nothing?

Without a sample, or more logs, there is little we can do to assist here.

GuidoNeele commented 3 years ago

You're right I will alter the code and rethrow the exception, this might give us a better clue of what's going on. Will report back if I know more.

rachelkang commented 2 years ago

We will be closing this issue as it has been over 30 days since we have heard any updates. If you are still experiencing this issue, please provide a sample and full build logs and then click the Reopen Issue button. Thank you!