16

Got the crash report below, but have no clue why it would be happening and how to fix it.

SIGABRT ABORT at 0x000000019aa3258c

libsystem_kernel.dylib __pthread_kill

Thread : Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0x000000019aa3258c __pthread_kill + 8
1  libsystem_pthread.dylib        0x000000019aab516c pthread_kill + 104
2  libsystem_c.dylib              0x000000019a9c6808 abort + 112
3  libc++abi.dylib                0x0000000199bec994 __cxa_bad_cast
4  libc++abi.dylib                0x0000000199c07184 std::__terminate(void (*)()) + 44
5  libc++abi.dylib                0x0000000199c06d3c __cxa_rethrow + 144
6  libobjc.A.dylib                0x000000019a3443a8 objc_exception_rethrow + 44
7  CoreFoundation                 0x000000018dd3d74c CFRunLoopRunSpecific + 576
8  GraphicsServices               0x0000000193a21c0c GSEventRunModal + 168
9  UIKit                          0x0000000190e6efdc UIApplicationMain + 1156
10 *************                  0x00000001000a5c80 main (main.m:17)
11 libdyld.dylib                  0x000000019a937aa0 start + 4
daihovey
  • 3,485
  • 13
  • 66
  • 110
  • 2
    What you're seeing is an Objective C exception being thrown. You're app isn't catching it, so the OS is terminating your app. You can start by turning on Objective-C exception breakpoints and breaking on a thrown exception in the debugger. Then run your app and get it to happen again. – user1118321 May 17 '14 at 18:10
  • I think the pthread_kill is a result of the unhandled exception, not the cause. As user1118321 said, it's very easy to find what causes this by setting an exception breakpoint. – sudo May 17 '14 at 19:37
  • @user1118321 Any idea how to catch the exception if I don't know how to recreate it? – daihovey May 18 '14 at 22:09
  • You can write code to catch the exception and do something with it, but if you don't know what's causing it, fixing the bug will be very hard. [See here](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Exceptions/Tasks/HandlingExceptions.html) for details on how to catch the exception and do something (log it, or display it to the user, or whatever). That will stop the immediate crash, though it may leave your app in a weird state if you're not careful about it. Additional logs from the device may also give a clue what happened. – user1118321 May 18 '14 at 22:35

1 Answers1

12

To make it easier to see where the crash is originating, change your main.m file as follows:

int main(int argc, char* argv[])
{
    @autoreleasepool
    {
        int returnValue;
        @try
        {
            returnValue = UIApplicationMain(argc, argv, nil, 
                NSStringFromClass([MyAppDelegate class]));
        }
        @catch (NSException* exception)
        {
            LogError(@"Uncaught exception: %@, %@", [exception description], 
                [exception callStackSymbols]);
            @throw exception;
        }
        return returnValue;
    }
}

. . . or as others have suggested, set an exception breakpoint.

If your crash is only happening "in the wild" you'll have to resymbolicate your crash logs. Services like Hockey or Test Flight do this for you, or it can be done manually following this process.

Community
  • 1
  • 1
Jasper Blues
  • 28,258
  • 22
  • 102
  • 185
  • 1
    _(I'm sorry for not knowing anything about C or Xcode, but)_ how do I import LogError? I located main.m. I'm getting `Implicit declaration of function 'LogError' is invalid in C99`. – Carolus Dec 16 '19 at 11:19
  • 1
    @Carolus That was just for example, you can do anything you like here. If you're just getting started I suggest to replace with NSLog – Jasper Blues Dec 17 '19 at 04:23