groveale
groveale

Reputation: 477

More details from crash log Xamarin.iOS

One my test flight users is experiencing a crash everytime they load the app. I have been unable to reproduce this on my test device or simulators.

I have the crash report and believe I have symbolicated it fully, following this blog.

However I can't map the error back to my code:

Date/Time:           2017-09-04 20:37:34.8879 +0100
Launch Time:         2017-09-04 20:36:50.5258 +0100
OS Version:          iPhone OS 10.2.1 (14D27)
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x0000000185433014 __pthread_kill + 8
1   libsystem_pthread.dylib         0x00000001854fb450 pthread_kill + 112 (pthread.c:1366)
2   libsystem_c.dylib               0x00000001853a7400 abort + 140 (abort.c:91)
3   planit                          0x0000000101235da8 mono_handle_native_crash (mini-exceptions.c:2548)
4   libsystem_platform.dylib        0x00000001854f5348 _sigtramp + 52 (sigtramp.c:115)
5   libsystem_pthread.dylib         0x00000001854fb450 pthread_kill + 112 (pthread.c:1366)
6   libsystem_c.dylib               0x00000001853a7400 abort + 140 (abort.c:91)
7   planit                          0x0000000101333414 xamarin_printf (runtime.m:2218)
8   planit                          0x0000000101271a9c mono_invoke_unhandled_exception_hook (exception.c:1084)
9   planit                          0x00000001012359e4 mono_handle_exception_internal (mini-exceptions.c:1886)
10  planit                          0x0000000101234a84 mono_handle_exception (mini-exceptions.c:2117)
11  planit                          0x000000010122d458 mono_arm_throw_exception (exceptions-arm64.c:411)
12  planit                          0x000000010041c278 throw_exception + 168
13  planit                          0x000000010032289c System_Runtime_ExceptionServices_ExceptionDispatchInfo_Throw + 44
14  planit                          0x00000001003252e4 System_Runtime_CompilerServices_AsyncMethodBuilderCore__c__ThrowAsyncb__6_0_object + 84
15  planit                          0x0000000100c2f808 UIKit_UIKitSynchronizationContext__Postc__AnonStorey0__m__0 (UIKitSynchronizationContext.cs:24)
16  planit                          0x0000000100c1be34 Foundation_NSAsyncActionDispatcher_Apply (NSAction.cs:163)
17  planit                          0x00000001003ecc24 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 244
18  planit                          0x0000000101243010 mono_jit_runtime_invoke (mini-runtime.c:2526)
19  planit                          0x00000001012a7df0 do_runtime_invoke (object.c:2829)
20  planit                          0x00000001012a7d50 mono_runtime_invoke (object.c:2983)
21  planit                          0x00000001000a8204 native_to_managed_trampoline_1(objc_object*, objc_selector*, _MonoMethod**, unsigned int) (registrar.m:25)
22  planit                          0x00000001000a853c -[__MonoMac_NSAsyncActionDispatcher xamarinApplySelector] (registrar.m:4355)
23  Foundation                      0x0000000186f79048 __NSThreadPerformPerform + 340 (NSThread.m:1247)
24  CoreFoundation                  0x0000000186412b5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1943)
25  CoreFoundation                  0x00000001864124a4 __CFRunLoopDoSources0 + 524 (CFRunLoop.c:1989)
26  CoreFoundation                  0x00000001864100a4 __CFRunLoopRun + 804 (CFRunLoop.c:2821)
27  CoreFoundation                  0x000000018633e2b8 CFRunLoopRunSpecific + 444 (CFRunLoop.c:3113)
28  GraphicsServices                0x0000000187df2198 GSEventRunModal + 180 (GSEvent.c:2245)
29  UIKit                           0x000000018c3857fc -[UIApplication _run] + 684 (UIApplication.m:2650)
30  UIKit                           0x000000018c380534 UIApplicationMain + 208 (UIApplication.m:4092)
31  planit                          0x0000000100c6fc10 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr (/<unknown>:1)
32  planit                          0x0000000100c2de8c UIKit_UIApplication_Main_string___intptr_intptr (UIApplication.cs:79)
33  planit                          0x0000000100c2de4c UIKit_UIApplication_Main_string___string_string (UIApplication.cs:63)
34  planit                          0x00000001000cbef4 planit_Application_Main_string__ (Main.cs:13)
35  planit                          0x00000001003ecc24 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 244
36  planit                          0x0000000101243010 mono_jit_runtime_invoke (mini-runtime.c:2526)
37  planit                          0x00000001012a7df0 do_runtime_invoke (object.c:2829)
38  planit                          0x00000001012aa7bc do_exec_main_checked (object.c:4624)
39  planit                          0x000000010122cc68 mono_jit_exec (driver.g.c:1040)
40  planit                          0x0000000101337168 xamarin_main (monotouch-main.m:482)
41  planit                          0x00000001000c75bc main (main.m:79)
42  libdyld.dylib                   0x00000001853215b8 start + 4

Can anyone point me in the right direction?

Upvotes: 1

Views: 976

Answers (1)

JoeTomks
JoeTomks

Reputation: 3276

The way we keep track of exceptions that are crashing the applications we've asked our testers to look through is by hooking into the global exception handler for iOS, and to use a class we wrote to record the information to IO.

Class:

using System;
using System.IO;
using UIKit;

namespace namespace.TestingLogs
{
    public static class ApplicationLog
    {
        private static string _filename = "LogFile-";

        public static void CreateFile(string SessionFilename)
        {
            _filename += SessionFilename;

            var docs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filename = Path.Combine(docs, _filename);
            var Device = UIDevice.CurrentDevice;
            File.AppendAllText(filename, ("======Device Information======" + Environment.NewLine));
            File.AppendAllText(filename, ("Battery Level: " + Device.BatteryLevel + Environment.NewLine));
            File.AppendAllText(filename, ("Model: " + Device.Model + Environment.NewLine));
            File.AppendAllText(filename, ("System Version: " + Device.SystemVersion + Environment.NewLine));
            File.AppendAllText(filename, ("[" + DateTime.UtcNow.ToString() + "]" + "======Start Log======" + Environment.NewLine + Environment.NewLine));
            Console.WriteLine("[] = " + filename);
        }

        public static void AppendFile(string appendText)
        {
            var txt = Environment.NewLine + appendText;

            var docs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filename = Path.Combine(docs, _filename);
            File.AppendAllText(filename, txt);
        }
    }

    public class ExitAppException : Exception
    {
        public ExitAppException() { }
        public ExitAppException(string message) : base(message) { }
        public ExitAppException(string message, Exception inner) :
        base(message, inner)
        { }
    }
}

Hook into the global unhandled event in AppDelegate.cs by doing the following in the 'FinishedLaunching' Method:

        AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) =>
        {
            try
            {
                //Record the error in our application logs

                ApplicationLog.AppendFile(
                    DateTime.Now.ToString() + "  :  " + "[CRITICAL GLOBALLY HANDLED EXCEPTION] - Critical exception has been hit! - Message: " + e.ExceptionObject +
                        Environment.NewLine + Environment.NewLine +
                            "========= Critcal Error has been hit, application closed =========" +
                                Environment.NewLine + Environment.NewLine
                    );
            }
            catch (Exception genEx)
            {
                var Error = genEx.Message;
            }
        };

Use whatever wording best suits you obviously. Feel free to use a string builder instead of the way we do it, but the general concept is the same. Your user can then download something like 'macgo iphone explorer' (it's free) and access the applications documents folder, the log file will be in there, so then they just email it to you. Hope this helps a little.

Upvotes: 1

Related Questions