Xamarin iOS SIGABRT Crash



我有一个Xamarin iOS应用程序不断崩溃,下面是崩溃报告。

我不知道问题是什么,也不知道它发生在哪里。看起来可能是json问题?任何帮助都会很棒。

Exception Type:  SIGABRT
Exception Codes: #0 at 0x23464c84
Crashed Thread:  7
Thread 0:
0   libsystem_kernel.dylib               0x23450c24 mach_msg_trap + 20
1   CoreFoundation                       0x23793355 __CFRunLoopServiceMachPort + 134
2   CoreFoundation                       0x237916dd __CFRunLoopRun + 1034
3   CoreFoundation                       0x236e4bf9 CFRunLoopRunSpecific + 518
4   CoreFoundation                       0x236e49e5 CFRunLoopRunInMode + 106
5   GraphicsServices                     0x24930ac9 GSEventRunModal + 158
6   UIKit                                0x27974ba1 UIApplicationMain + 142
7   IntooligenceMobileiOS                0x0020630c wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 270
8   IntooligenceMobileiOS                0x0019c434 MonoTouch_UIKit_UIApplication_Main_string___intptr_intptr + 50
9   IntooligenceMobileiOS                0x0019c3f4 MonoTouch_UIKit_UIApplication_Main_string___string_string + 202
10  IntooligenceMobileiOS                0x000b7680 Intooligence_Mobile_iOS_Application_Main_string__ + 46
11  IntooligenceMobileiOS                0x0046ee54 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 254
12  IntooligenceMobileiOS                0x00ad3ff7 mono_jit_runtime_invoke (mini-runtime.c:2323)
13  IntooligenceMobileiOS                0x00b24855 mono_runtime_invoke (object.c:2783)
14  IntooligenceMobileiOS                0x00b27f17 mono_runtime_exec_main (object.c:4040)
15  IntooligenceMobileiOS                0x00b89528 xamarin_main (monotouch-main.m:404)
16  IntooligenceMobileiOS                0x00a4afd1 main (main.armv7.m:59)
17  ???                                  0x23393873 0x0 + 0
Thread 1:
0   libsystem_kernel.dylib               0x23466320 kevent_qos + 24
1   libdispatch.dylib                    0x2335ddf7 _dispatch_mgr_thread$VARIANT$mp + 36
Thread 2:
0   libsystem_kernel.dylib               0x23450c74 semaphore_wait_trap + 8
1   IntooligenceMobileiOS                0x00afc2ab finalizer_thread (gc.c:1096)
2   IntooligenceMobileiOS                0x00b3ff47 start_wrapper (threads.c:723)
3   IntooligenceMobileiOS                0x00b59889 inner_start_thread (mono-threads-posix.c:97)
4   IntooligenceMobileiOS                0x00b72cb7 GC_start_routine (pthread_support.c:1502)
5   libsystem_pthread.dylib              0x2350985b _pthread_body + 136
6   libsystem_pthread.dylib              0x235097cf _pthread_start + 108
7   libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 3:
0   libsystem_kernel.dylib               0x234649c0 __psynch_cvwait + 24
1   libsystem_pthread.dylib              0x23509c99 pthread_cond_wait + 38
2   IntooligenceMobileiOS                0x00b3a9fb worker_thread (threadpool-ms.c:501)
3   IntooligenceMobileiOS                0x00b3ff47 start_wrapper (threads.c:723)
4   IntooligenceMobileiOS                0x00b59889 inner_start_thread (mono-threads-posix.c:97)
5   IntooligenceMobileiOS                0x00b72cb7 GC_start_routine (pthread_support.c:1502)
6   libsystem_pthread.dylib              0x2350985b _pthread_body + 136
7   libsystem_pthread.dylib              0x235097cf _pthread_start + 108
8   libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 4:
0   libsystem_kernel.dylib               0x234649c0 __psynch_cvwait + 24
1   libsystem_pthread.dylib              0x23509c99 pthread_cond_wait + 38
2   IntooligenceMobileiOS                0x00b3a9fb worker_thread (threadpool-ms.c:501)
3   IntooligenceMobileiOS                0x00b3ff47 start_wrapper (threads.c:723)
4   IntooligenceMobileiOS                0x00b59889 inner_start_thread (mono-threads-posix.c:97)
5   IntooligenceMobileiOS                0x00b72cb7 GC_start_routine (pthread_support.c:1502)
6   libsystem_pthread.dylib              0x2350985b _pthread_body + 136
7   libsystem_pthread.dylib              0x235097cf _pthread_start + 108
8   libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 5:
0   libsystem_kernel.dylib               0x23450c24 mach_msg_trap + 20
1   CoreFoundation                       0x23793355 __CFRunLoopServiceMachPort + 134
2   CoreFoundation                       0x237916dd __CFRunLoopRun + 1034
3   CoreFoundation                       0x236e4bf9 CFRunLoopRunSpecific + 518
4   CoreFoundation                       0x236e49e5 CFRunLoopRunInMode + 106
5   CFNetwork                            0x23d2781f +[NSURLConnection(Loader) _resourceLoadLoop:] + 484
6   Foundation                           0x23fe9165 __NSThread__start__ + 1146
7   libsystem_pthread.dylib              0x2350985b _pthread_body + 136
8   libsystem_pthread.dylib              0x235097cf _pthread_start + 108
9   libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 6:
0   libsystem_kernel.dylib               0x23464f14 __select + 20
1   libsystem_pthread.dylib              0x2350985b _pthread_body + 136
2   libsystem_pthread.dylib              0x235097cf _pthread_start + 108
3   libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 7 Crashed:
0   libsystem_kernel.dylib               0x23464c84 __pthread_kill + 8
1   libsystem_pthread.dylib              0x2350a733 pthread_kill + 60
2   libsystem_c.dylib                    0x233fb0ad abort + 106
3   IntooligenceMobileiOS                0x00b68efd GC_add_to_heap (alloc.c:840)
4   IntooligenceMobileiOS                0x00b69119 GC_expand_hp_inner (alloc.c:994)
5   IntooligenceMobileiOS                0x00b6928d GC_collect_or_expand (alloc.c:1070)
6   IntooligenceMobileiOS                0x00b6943f GC_allocobj (alloc.c:1125)
7   IntooligenceMobileiOS                0x00b6dadb GC_generic_malloc_inner (malloc.c:136)
8   IntooligenceMobileiOS                0x00b6dc73 GC_generic_malloc (malloc.c:192)
9   IntooligenceMobileiOS                0x00b6dd7d GC_malloc_atomic (malloc.c:270)
10  IntooligenceMobileiOS                0x00ae2953 mono_gc_alloc_string (boehm-gc.c:680)
11  IntooligenceMobileiOS                0x00314700 wrapper_managed_to_native_string_FastAllocateString_int + 90
12  IntooligenceMobileiOS                0x00314960 string_CtorCharArrayStartLength_char___int_int + 86
13  IntooligenceMobileiOS                0x0031b060 string_CreateString_char___int_int + 50
14  IntooligenceMobileiOS                0x00312190 wrapper_managed_to_managed_string__ctor_char___int_int + 50
15  IntooligenceMobileiOS                0x003ea500 System_NumberFormatter_FormatDecimal_int_System_Globalization_NumberFormatInfo + 142
16  IntooligenceMobileiOS                0x003e9d64 System_NumberFormatter_IntegerToString_string_System_IFormatProvider + 222
17  IntooligenceMobileiOS                0x003e993c System_NumberFormatter_NumberToString_string_long_System_IFormatProvider + 94
18  IntooligenceMobileiOS                0x002bf160 System_Number_FormatInt64_long_string_System_Globalization_NumberFormatInfo + 50
19  IntooligenceMobileiOS                0x002adcb4 ut_2706 + 82
20  IntooligenceMobileiOS                0x008d11ec Newtonsoft_Json_JsonConvert_ToString_long + 90
21  IntooligenceMobileiOS                0x008dd3fc Newtonsoft_Json_JsonTextWriter_WriteValue_long + 50
22  IntooligenceMobileiOS                0x008f8ce8 Newtonsoft_Json_Linq_JValue_WriteTo_Newtonsoft_Json_JsonWriter_Newtonsoft_Json_JsonConverter__ + 522
23  IntooligenceMobileiOS                0x008f5a00 Newtonsoft_Json_Linq_JProperty_WriteTo_Newtonsoft_Json_JsonWriter_Newtonsoft_Json_JsonConverter__ + 90
24  IntooligenceMobileiOS                0x008f34cc Newtonsoft_Json_Linq_JObject_WriteTo_Newtonsoft_Json_JsonWriter_Newtonsoft_Json_JsonConverter__ + 94
25  IntooligenceMobileiOS                0x008e53f0 Newtonsoft_Json_Linq_JToken_ToString_Newtonsoft_Json_Formatting_Newtonsoft_Json_JsonConverter__ + 234
26  IntooligenceMobileiOS                0x008e52f8 Newtonsoft_Json_Linq_JToken_ToString + 58
27  IntooligenceMobileiOS                0x0081d098 Intooligence_Mobile_Core_Sync_SyncAdapter_ProcessSyncResponse_string + 2722
28  IntooligenceMobileiOS                0x0081b390 Intooligence_Mobile_Core_Sync_SyncAdapter_DoSync_int_bool + 638
29  IntooligenceMobileiOS                0x0081a938 Intooligence_Mobile_Core_Sync_SyncAdapter_SyncSynchronously_bool + 706
30  IntooligenceMobileiOS                0x0085b254 Intooligence_Mobile_Core_Sync_SyncAdapter__BeginSyncc__AnonStorey0__m__0 + 30
31  IntooligenceMobileiOS                0x00346620 System_Threading_Tasks_Task_InnerInvoke + 98
32  IntooligenceMobileiOS                0x00345e2c System_Threading_Tasks_Task_Execute + 90
33  IntooligenceMobileiOS                0x003465b0 System_Threading_Tasks_Task_ExecutionContextCallback_object + 98
34  IntooligenceMobileiOS                0x0034f930 System_Threading_ExecutionContext_RunInternal_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 490
35  IntooligenceMobileiOS                0x0034f738 System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 50
36  IntooligenceMobileiOS                0x00346514 System_Threading_Tasks_Task_ExecuteWithThreadLocal_System_Threading_Tasks_Task_ + 354
37  IntooligenceMobileiOS                0x00346328 System_Threading_Tasks_Task_ExecuteEntry_bool + 230
38  IntooligenceMobileiOS                0x003461cc System_Threading_Tasks_Task_System_Threading_IThreadPoolWorkItem_ExecuteWorkItem + 30
39  IntooligenceMobileiOS                0x00353250 System_Threading_ThreadPoolWorkQueue_Dispatch + 554
40  IntooligenceMobileiOS                0x003549fc System_Threading__ThreadPoolWaitCallback_PerformWaitCallback + 18
41  IntooligenceMobileiOS                0x0046ee54 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 254
42  IntooligenceMobileiOS                0x00ad3ff7 mono_jit_runtime_invoke (mini-runtime.c:2323)
43  IntooligenceMobileiOS                0x00b24855 mono_runtime_invoke (object.c:2783)
44  IntooligenceMobileiOS                0x00b3a913 worker_thread (threadpool-ms.c:623)
45  IntooligenceMobileiOS                0x00b3ff47 start_wrapper (threads.c:723)
46  IntooligenceMobileiOS                0x00b59889 inner_start_thread (mono-threads-posix.c:97)
47  IntooligenceMobileiOS                0x00b72cb7 GC_start_routine (pthread_support.c:1502)
48  libsystem_pthread.dylib              0x2350985b _pthread_body + 136
49  libsystem_pthread.dylib              0x235097cf _pthread_start + 108
50  libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 8:
0   libsystem_kernel.dylib               0x234649c0 __psynch_cvwait + 24
1   libsystem_pthread.dylib              0x23509cd9 pthread_cond_timedwait + 42
2   IntooligenceMobileiOS                0x00b43d83 _wapi_handle_timedwait_signal_handle (handles.c:1514)
3   IntooligenceMobileiOS                0x00b4e32d wapi_WaitForSingleObjectEx (wait.c:196)
4   IntooligenceMobileiOS                0x00b3cd0d ves_icall_System_Threading_WaitHandle_WaitOne_internal (threads.c:1447)
5   IntooligenceMobileiOS                0x003d1bf8 wrapper_managed_to_native_System_Threading_WaitHandle_WaitOne_internal_System_Threading_WaitHandle_intptr_int_bool + 126
6   IntooligenceMobileiOS                0x003d1f24 System_Threading_WaitHandle_WaitOne_int_bool + 142
7   IntooligenceMobileiOS                0x003d1fc0 System_Threading_WaitHandle_WaitOne_int + 50
8   IntooligenceMobileiOS                0x003d15a4 System_Threading_Timer_Scheduler_SchedulerThread + 2090
9   IntooligenceMobileiOS                0x00350b20 System_Threading_ThreadHelper_ThreadStart_Context_object + 206
10  IntooligenceMobileiOS                0x0034f930 System_Threading_ExecutionContext_RunInternal_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 490
11  IntooligenceMobileiOS                0x0034f738 System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 50
12  IntooligenceMobileiOS                0x0034f6b8 System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object + 98
13  IntooligenceMobileiOS                0x00350c74 System_Threading_ThreadHelper_ThreadStart + 62
14  IntooligenceMobileiOS                0x0046ee54 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 254
15  IntooligenceMobileiOS                0x00ad3ff7 mono_jit_runtime_invoke (mini-runtime.c:2323)
16  IntooligenceMobileiOS                0x00b24855 mono_runtime_invoke (object.c:2783)
17  IntooligenceMobileiOS                0x00b3ffbb start_wrapper (threads.c:729)
18  IntooligenceMobileiOS                0x00b59889 inner_start_thread (mono-threads-posix.c:97)
19  IntooligenceMobileiOS                0x00b72cb7 GC_start_routine (pthread_support.c:1502)
20  libsystem_pthread.dylib              0x2350985b _pthread_body + 136
21  libsystem_pthread.dylib              0x235097cf _pthread_start + 108
22  libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 9:
0   libsystem_kernel.dylib               0x23464f14 __select + 20
1   IntooligenceMobileiOS                0x00b37b85 poll_event_wait (threadpool-ms-io-poll.c:152)
2   IntooligenceMobileiOS                0x00b376cb selector_thread (threadpool-ms-io.c:447)
3   IntooligenceMobileiOS                0x00b3ff47 start_wrapper (threads.c:723)
4   IntooligenceMobileiOS                0x00b59889 inner_start_thread (mono-threads-posix.c:97)
5   IntooligenceMobileiOS                0x00b72cb7 GC_start_routine (pthread_support.c:1502)
6   libsystem_pthread.dylib              0x2350985b _pthread_body + 136
7   libsystem_pthread.dylib              0x235097cf _pthread_start + 108
8   libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 10:
0   libsystem_kernel.dylib               0x234649c0 __psynch_cvwait + 24
1   libsystem_pthread.dylib              0x23509c99 pthread_cond_wait + 38
2   IntooligenceMobileiOS                0x00b3a9fb worker_thread (threadpool-ms.c:501)
3   IntooligenceMobileiOS                0x00b3ff47 start_wrapper (threads.c:723)
4   IntooligenceMobileiOS                0x00b59889 inner_start_thread (mono-threads-posix.c:97)
5   IntooligenceMobileiOS                0x00b72cb7 GC_start_routine (pthread_support.c:1502)
6   libsystem_pthread.dylib              0x2350985b _pthread_body + 136
7   libsystem_pthread.dylib              0x235097cf _pthread_start + 108
8   libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 11:
0   libsystem_kernel.dylib               0x234649c0 __psynch_cvwait + 24
1   libsystem_pthread.dylib              0x23509c99 pthread_cond_wait + 38
2   IntooligenceMobileiOS                0x00b3a9fb worker_thread (threadpool-ms.c:501)
3   IntooligenceMobileiOS                0x00b3ff47 start_wrapper (threads.c:723)
4   IntooligenceMobileiOS                0x00b59889 inner_start_thread (mono-threads-posix.c:97)
5   IntooligenceMobileiOS                0x00b72cb7 GC_start_routine (pthread_support.c:1502)
6   libsystem_pthread.dylib              0x2350985b _pthread_body + 136
7   libsystem_pthread.dylib              0x235097cf _pthread_start + 108
8   libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 12:
0   libsystem_kernel.dylib               0x2346588c __workq_kernreturn + 8
1   libsystem_pthread.dylib              0x23507718 start_wqthread + 6
Thread 13:
0   libsystem_kernel.dylib               0x23465024 __semwait_signal + 24
1   IntooligenceMobileiOS                0x00b4f6a5 wapi_SleepEx (wthreads.c:289)
2   IntooligenceMobileiOS                0x00b3a27d monitor_thread (threadpool-ms.c:833)
3   IntooligenceMobileiOS                0x00b3ff47 start_wrapper (threads.c:723)
4   IntooligenceMobileiOS                0x00b59889 inner_start_thread (mono-threads-posix.c:97)
5   IntooligenceMobileiOS                0x00b72cb7 GC_start_routine (pthread_support.c:1502)
6   libsystem_pthread.dylib              0x2350985b _pthread_body + 136
7   libsystem_pthread.dylib              0x235097cf _pthread_start + 108
8   libsystem_pthread.dylib              0x23507724 thread_start + 6
Thread 7 crashed with ARM Thread State:
    pc: 0x23464c84     r7: 0x1f39a14c     sp: 0x1f39a140     r0: 0x00000000 
    r1: 0x00000000     r2: 0x00000000     r3: 0x00000000     r4: 0x00000006 
    r5: 0x1f39b000     r6: 0x00f2cc6c     r8: 0x00f2cb54     r9: 0x3a096908 
   r10: 0x00000001    r11: 0x15e7e000     ip: 0x00000148     lr: 0x2350a733 
  cpsr: 0x00000010 
Link Register Analysis:
  Symbol: pthread_kill + 60
  Description: We have determined that the link register (lr) is very likely to contain the return address of frame #0's calling function, and have inserted it into the crashing thread's backtrace as frame #1 to aid in analysis. This determination was made by applying a heuristic to determine whether the crashing function was likely to have created a new stack frame at the time of the crash.
  Type: 1

SIGABRT异常总是非常模糊,以找出真正的错误。线程7,步骤15-18提供了合理数量的情报来了解实际发生了什么。它肯定与JSON解析有关。这与JSON文件中一些无法处理/解析的数值有关。

读取JSON数据时可能的原因:

  • JSON中的数值格式不正确
  • 用户区域设置与预期的不同(.vs,)。这是不太可能的,因为Json.net并没有提供开箱即用的功能。但如果应用自定义转换器,则可能发生这种情况

写入JSON数据时可能的原因:

  • 检查您可能已应用的序列化规则

将代码封装在try/catch中可能会为您提供有关特定问题的更多详细信息。还要检查您是否在JsonSerializerSettings中添加了任何自定义转换器。

这是您正在命中的中止:https://github.com/mono/mono/blob/9fd216db06cd8150d5d859aa06fb9f7571d66548/libgc/alloc.c#L840

看起来该应用程序在Boehm垃圾回收器中达到了某种内存限制。

我的建议是在项目的iOS Build选项中切换到SGen垃圾回收器,这应该可以解决问题(因为SGen垃圾收集器没有这种类型的内存限制)。

要在设备上的发布版本上获得类似崩溃的控制台输出:
将设备连接到Mac
打开XCode
转到窗口->设备和模拟器
单击"打开设备的控制台"
在搜索窗口中键入您的应用程序名称以筛选输出

我就是这样发现的。问题中发布的崩溃日志没有帮助,因为这只是苹果主线程崩溃。

对我们来说,崩溃是由使用一个不推荐使用的类引起的,即UISearchDisplayController,它应该被UISearchController取代
它在iOS12中继续工作,但在iOS13中没有。它在iOS8中被弃用了,尽管我认为这很公平。

您可能需要将应用程序上传到app Store Connect并通过TestFlight运行才能查看日志,但不确定。

此外,这可能无关紧要,但请转到您的iPhone设置->隐私->分析->与应用程序开发人员共享并共享iPhone分析

从这里复制的答案(我自己的):
Xamarin.iOS应用程序在iOS13 上启动时崩溃