1

I'm getting a "random" crash on my last application (around the 2% of the users seems to experience the crash) but I'm not able to find any useful info from the crash logs. It seems that I don't have any reference to my code and I find extremely difficult to understand what is going on and how this crash is generated... I paste here the relevant part of the crash log, any hints or thoughts about it? is there anything obvious that I'm missing ...

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

Last Exception Backtrace:
0   CoreFoundation                  0x18266d900 __exceptionPreprocess + 124 (NSException.m:162)
1   libobjc.A.dylib                 0x181cdbf80 objc_exception_throw + 56 (objc-exception.mm:531)
2   CoreFoundation                  0x18266d7d0 +[NSException raise:format:arguments:] + 108 (NSException.m:131)
3   Foundation                      0x182fe099c -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 112 (NSException.m:152)
4   UIKit                           0x187608ac0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 3216 (UIApplication.m:3315)
5   UIKit                           0x1876055c0 -[UIApplication workspaceDidEndTransaction:] + 168 (UIApplication.m:2662)
6   FrontBoardServices              0x183c23790 -[FBSSerialQueue _performNext] + 184 (FBSSerialQueue.m:157)
7   FrontBoardServices              0x183c23b10 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 (FBSSerialQueue.m:204)
8   CoreFoundation                  0x182624efc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1761)
9   CoreFoundation                  0x182624990 __CFRunLoopDoSources0 + 540 (CFRunLoop.c:1807)
10  CoreFoundation                  0x182622690 __CFRunLoopRun + 724 (CFRunLoop.c:2536)
11  CoreFoundation                  0x182551680 CFRunLoopRunSpecific + 384 (CFRunLoop.c:2814)
12  UIKit                           0x1873ce580 -[UIApplication _run] + 460 (UIApplication.m:2503)
13  UIKit                           0x1873c8d90 UIApplicationMain + 204 (UIApplication.m:3681)
14  KickLow                         0x100153604 0x100024000 + 1242628
15  libdyld.dylib                   0x1820f28b8 start + 4 (start_glue.s:80)

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x0000000182210140 __pthread_kill + 8
1   libsystem_pthread.dylib         0x00000001822d8ef8 pthread_kill + 112 (pthread.c:1247)
2   libsystem_c.dylib               0x0000000182181dac abort + 140 (abort.c:91)
3   libc++abi.dylib                 0x0000000181cb53f4 abort_message + 132 (abort_message.cpp:47)
4   libc++abi.dylib                 0x0000000181cd1e98 default_terminate_handler() + 304 (cxa_default_handlers.cpp:67)
5   libobjc.A.dylib                 0x0000000181cdc248 _objc_terminate() + 124 (objc-exception.mm:678)
6   libc++abi.dylib                 0x0000000181ccef44 std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:62)
7   libc++abi.dylib                 0x0000000181cceb10 __cxa_rethrow + 144 (cxa_exception.cpp:480)
8   libobjc.A.dylib                 0x0000000181cdc120 objc_exception_rethrow + 44 (objc-exception.mm:581)
9   CoreFoundation                  0x0000000182551728 CFRunLoopRunSpecific + 552 (CFRunLoop.c:2827)
10  UIKit                           0x00000001873ce580 -[UIApplication _run] + 460 (UIApplication.m:2503)
11  UIKit                           0x00000001873c8d90 UIApplicationMain + 204 (UIApplication.m:3681)
12  KickLow                         0x0000000100153604 0x100024000 + 1242628
13  libdyld.dylib                   0x00000001820f28b8 start + 4 (start_glue.s:80)
MatterGoal
  • 16,038
  • 19
  • 109
  • 186
  • Are you using notifications? If so make sure that they are properly removed when de-allocating a receiver. – john elemans Feb 12 '16 at 19:05
  • 3
    Your issue seem same to [weird crash when launching app from Notification Center](http://stackoverflow.com/questions/26371462/weird-crash-when-launching-app-from-notification-center) – aman.sood Feb 15 '16 at 17:02
  • @aman.sood you are right. Please fill an answer so that you can get the bounty. – MatterGoal Feb 15 '16 at 18:01

2 Answers2

4

Looking at the disassembly of the -[UIApplication _runWithMainScene:transitionContext:completion:] method, here is what we find out:

0x111ef155d <+3038>: movq   0xd166b4(%rip), %rdi      ; (void *)0x0000000111ce4b10: NSAssertionHandler
0x111ef1564 <+3045>: movq   0xce0bcd(%rip), %rsi      ; "currentHandler"
0x111ef156b <+3052>: callq  *0xd64c5f(%rip)           ; (void *)0x0000000113e36800: objc_msgSend
0x111ef1571 <+3058>: movq   %rax, %rdi
0x111ef1574 <+3061>: callq  0x1129c0046               ; symbol stub for: objc_retainAutoreleasedReturnValue
0x111ef1579 <+3066>: movq   %rax, %r15
0x111ef157c <+3069>: leaq   0xda427d(%rip), %rax      ; @"Application windows are expected to have a root view controller at the end of application launch"
0x111ef1583 <+3076>: movq   %rax, (%rsp)
0x111ef1587 <+3080>: movl   $0xd3c, %r9d              ; imm = 0xD3C 
0x111ef158d <+3086>: xorl   %eax, %eax
0x111ef158f <+3088>: movq   %r15, %rdi
0x111ef1592 <+3091>: movq   0xce0ba7(%rip), %rsi      ; "handleFailureInMethod:object:file:lineNumber:description:"

So it seems your app is creating a window with no root view controller. Perhaps your view controller fails to create.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
-1

Moved my comment as answer. @MatterGoal glad to know it helped.

Your issue seem similar to weird crash when launching app from Notification Center

Either your code or a third-party library you are using is manually spinning the runloop. This is causing -workspaceDidEndTransaction: to be called re-entrantly and triggers a use after free. If you set a breakpoint on -[NSRunLoop runMode:beforeDate:] and -[NSRunLoop runUntilDate:], it should hit with the guilty code being on the previous stack frame.

While manually spinning the run loop is never recommended, if you can delay doing it until your application finishes starting up (all the launch app delegate calls received) you should avoid hitting this crash.

Community
  • 1
  • 1
aman.sood
  • 872
  • 7
  • 19
  • 1
    Please include more than just a link. As it currently stands, this does not qualify as an answer. – CaptJak Feb 16 '16 at 01:47
  • modified answer to include more details – aman.sood Feb 16 '16 at 08:14
  • The answer has been modified, can you kindly remove your downvote. – MatterGoal Feb 16 '16 at 14:34
  • 1
    This question is a duplicate of a question already asked, which is the exact question you are referencing in both your comment, and copying in your answer. Posting this answer is incorrect, leaving a comment referring to the question that this is a duplicate of, is correct. I'm sorry, but my down-vote remains. – CaptJak Feb 16 '16 at 20:24