ArrayTypeMismatchException, возникающее при инициализации AggregateException - PullRequest
2 голосов
/ 06 августа 2020

В моем приложении Xamarin.Forms я вижу случаи, когда происходит сбой фонового потока, приложение пытается создать исключение AggregateException для отправки в TaskScheduler.UnobservedTaskException, но выдает исключение ArrayTypeMismatchException в инициализаторе AggregateException. Кажется, это происходит только на iOS.

Об этом очень часто сообщают в AppCenter, и в настоящее время это моя самая популярная проблема sh. Однако воспроизвести не удалось. Когда я явно генерирую исключения в фоновых потоках, он может без проблем создавать AggregateExceptions. Любая помощь будет принята с благодарностью.

Вот соответствующая трассировка стека:

Exception Codes: #0 at 0x19083ad88
Crashed Thread:  6

Application Specific Information:
*** Terminating app due to uncaught exception 'SIGABRT', reason: 'Attempted to access an element as a type incompatible with the array.'

Xamarin Exception Stack:
System.ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.
  at (wrapper stelemref) System.Object.virt_stelemref_class_small_idepth(intptr,object)
  at System.AggregateException..ctor (System.String message, System.Collections.Generic.IList`1[T] innerExceptionInfos) <0x1006d41ec + 0x00127> in <7df0b59b3ac34c319d58e821ad54104a#eba08df608efe53844894d720d943b17>:0
  at System.AggregateException..ctor (System.String message, System.Collections.Generic.IEnumerable`1[T] innerExceptionInfos) <0x1006d40e4 + 0x000f3> in <7df0b59b3ac34c319d58e821ad54104a#eba08df608efe53844894d720d943b17>:0
  at System.Threading.Tasks.TaskExceptionHolder.Finalize () <0x1007820c4 + 0x000a7> in <7df0b59b3ac34c319d58e821ad54104a#eba08df608efe53844894d720d943b17>:0

Thread 6 Crashed:
0   libsystem_kernel.dylib               0x000000019083ad88 __pthread_kill + 8
1   libsystem_c.dylib                    0x00000001906a6934 abort + 96
2   My.Project.iOS                        0x000000010326e0f8 xamarin_unhandled_exception_handler.cold.1 + 32
3   My.Project.iOS                        0x000000010322557c xamarin_unhandled_exception_handler (runtime.m:1176)
4   My.Project.iOS                        0x00000001030e2d48 mono_invoke_unhandled_exception_hook (exception.c:1265)
5   My.Project.iOS                        0x00000001031962f4 mono_thread_internal_unhandled_exception (threads.c:5932)
6   My.Project.iOS                        0x00000001030e51b0 mono_gc_run_finalize (gc.c:340)
7   My.Project.iOS                        0x00000001031bbf18 sgen_gc_invoke_finalizers (sgen-gc.c:2773)
8   My.Project.iOS                        0x00000001030e644c finalizer_thread (gc.c:930)
9   My.Project.iOS                        0x0000000103196e08 start_wrapper_internal (threads.c:1222)
10  My.Project.iOS                        0x0000000103196c8c start_wrapper (threads.c:1295)
11  libsystem_pthread.dylib              0x000000019075bd98 _pthread_start + 152
12  libsystem_pthread.dylib              0x000000019075f74c thread_start + 4```
...