App is crashing with EXC_BAD_ACCESS exception only in RTL mode whereas the app is working fine in LTR mode. I'm running the app by forcing it in RTL mode as below,
Edit Scheme -> Run -> Option -> App Language -> Right to Left Pseudo Language.
It is crashing in UIApplicationMain with following stack trace
0x12495a1bb <+94>: movq 0x47896(%rip), %rsi ; "overflowEngineVarIndexForEngine:"
0x12495a1c2 <+101>: movq %r14, %rdi
0x12495a1c5 <+104>: movq %rbx, %rdx
0x12495a1c8 <+107>: callq *0x3d022(%rip) ; (void *)0x0000000113ecd7c0: objc_msgSend
0x12495a1ce <+113>: jmp 0x12495a1d5 ; <+120>
0x12495a1d0 <+115>: movl $0xffffffff, %eax ; imm = 0xFFFFFFFF
0x12495a1d5 <+120>: movq 0xc0(%rbx), %rcx
0x12495a1dc <+127>: movl %eax, %eax
0x12495a1de <+129>: movq %rax, %rdx
0x12495a1e1 <+132>: shrq $0x6, %rdx
-> 0x12495a1e5 <+136>: movq (%rcx,%rdx,8), %rcx Thread 1: EXC_BAD_ACCESS (code=2, address=0x6190201a4f78)
0x12495a1e9 <+140>: andl $0x3f, %eax
0x12495a1ec <+143>: shlq $0x5, %rax
0x12495a1f0 <+147>: leaq (%rcx,%rax), %r15
Crash Log Looks like this
Thread 0:: Dispatch queue: com.apple.main-thread
0 ??? 0x110739ad8 ???
1 ??? 0x111e93948 ???
2 CoreAutoLayout 0x128b4e3e9 -[NSISEngine negativeErrorVarForBrokenConstraintWithMarker:errorVar:] + 89
3 CoreAutoLayout 0x128b5716f -[NSISEngine removeConstraintWithMarker:] + 1102
4 CoreAutoLayout 0x128b6ca30 -[NSLayoutConstraint _removeFromEngine:] + 209
5 UIKitCore 0x13ecd4dd0 -[UIView _layoutEngine_willRemoveLayoutConstraint:] + 80
6 UIKitCore 0x13ecd589c -[UIView(UIConstraintBasedLayout) nsli_removeConstraint:] + 90
7 CoreAutoLayout 0x128b6de31 __55+[NSLayoutConstraint _addOrRemoveConstraints:activate:]_block_invoke + 53
8 CoreAutoLayout 0x128b5458f -[NSISEngine withBehaviors:performModifications:] + 84
9 CoreAutoLayout 0x128b6dd0a +[NSLayoutConstraint _addOrRemoveConstraints:activate:] + 398
10 UIKitCore 0x13ece22f8 -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 580
11 UIKitCore 0x13ece344d -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] + 154
12 UIKitCore 0x13ece4556 -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeededWithViewForVariableChangeNotifications:] + 374
13 UIKitCore 0x13ede1561 -[UIView _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 352
14 UIKitCore 0x13edf559f -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2305
15 QuartzCore 0x11b49302c CA::Layer::layout_if_needed(CA::Transaction*) + 526
16 QuartzCore 0x11b49e5b9 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 65
17 QuartzCore 0x11b3afb0c CA::Context::commit_transaction(CA::Transaction*, double, double*) + 626
18 QuartzCore 0x11b3e769b CA::Transaction::commit() + 735
19 QuartzCore 0x11b3e8b64 CA::Transaction::flush_as_runloop_observer(bool) + 60
20 CoreFoundation 0x11f3df055 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
21 CoreFoundation 0x11f3d99c2 __CFRunLoopDoObservers + 515
22 CoreFoundation 0x11f3d9f0d __CFRunLoopRun + 1161
23 CoreFoundation 0x11f3d96a7 CFRunLoopRunSpecific + 560
24 GraphicsServices 0x12793128a GSEventRunModal + 139
25 UIKitCore 0x13e7c2ad3 -[UIApplication _run] + 994
26 UIKitCore 0x13e7c79ef UIApplicationMain + 123
27 libswiftUIKit.dylib 0x1267f3c72 UIApplicationMain(_:_:_:_:) + 98
28 Bookings 0x105de34c0 main + 560 (main.swift:12)
29 dyld_sim 0x1170582bf start_sim + 10
30 dyld 0x20cd81310 start + 2432
I have enabled Constraint Error Breakpoint , Exception Breakpoint and Run Time Issue Breakpoint but have no luck in finding any clue about the issue. Have used instruments to find memory leaks but had no luck there too since it showed as no leaks.
So from crash logs it is clear that app is crashing coz of something went wrong inside Autolayout engine (which may be coz of some contradicting constraints) and I can't check all the constraints since app has huge number of them. How can find the root cause of this crash and fix this issue.
I would appreciate any help in finding the root cause of this crash issue.
Console info:
2015-11-15 23:26:42.824 SWPi2[1564:476501] *** -[__NSCFConstantString length]: message sent to deallocated instance 0x110d868a0
bt:
* thread #1: tid = 0x74555, 0x0000000110a9beaf CoreFoundation`___forwarding___ + 767, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
* frame #0: 0x0000000110a9beaf CoreFoundation`___forwarding___ + 767
frame #1: 0x0000000110a9bb28 CoreFoundation`__forwarding_prep_0___ + 120
frame #2: 0x0000000110a1abfc CoreFoundation`CFURLCreateStringByReplacingPercentEscapes + 60
frame #3: 0x0000000110a5cec6 CoreFoundation`URLPathToPOSIXPath + 38
frame #4: 0x0000000110a1a1e7 CoreFoundation`CFURLCreateStringWithFileSystemPath + 439
frame #5: 0x0000000110a16f2c CoreFoundation`CFURLCopyFileSystemPath + 364
frame #6: 0x0000000110b05b25 CoreFoundation`extractQuadrupleFromPathIfPossible + 1221
frame #7: 0x0000000110b3f8c9 CoreFoundation`+[CFPrefsSearchListSource withSearchListForIdentifier:container:perform:] + 185
frame #8: 0x0000000110b2d017 CoreFoundation`_CFPreferencesCopyAppValueWithContainer + 183
frame #9: 0x0000000117a4f134 libAccessibility.dylib`_copyValuePreference + 138
frame #10: 0x0000000117a4ee14 libAccessibility.dylib`_getBooleanPreference + 24
frame #11: 0x0000000117a52312 libAccessibility.dylib`_AXSQuickSpeakEnabled + 76
frame #12: 0x000000010f0d57ad UIKit`-[UIApplication(UIKitApplicationAccessibility) _accessibilitySetUpQuickSpeak] + 79
frame #13: 0x00000001101a7129 Foundation`__NSFireDelayedPerform + 402
frame #14: 0x0000000110aa6364 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
frame #15: 0x0000000110aa5f11 CoreFoundation`__CFRunLoopDoTimer + 1089
frame #16: 0x0000000110a678b1 CoreFoundation`__CFRunLoopRun + 1937
frame #17: 0x0000000110a66e98 CoreFoundation`CFRunLoopRunSpecific + 488
frame #18: 0x0000000111bf8ad2 GraphicsServices`GSEventRunModal + 161
frame #19: 0x000000010ecd6676 UIKit`UIApplicationMain + 171
frame #20: 0x000000010deb1c41 SWPi2`main(argc=1, argv=0x00007fff51def770) + 129 at main.m:7
frame #21: 0x000000011255b92d libdyld.dylib`start + 1
thread forwarding:
0x110a9bc80 <+208>: movq %rbx, -0x40(%rbp)
0x110a9bc84 <+212>: leaq 0x2a3a0d(%rip), %rsi ; "_NSZombie_"
0x110a9bc8b <+219>: movl $0xa, %edx
0x110a9bc90 <+224>: movq %r14, %rdi
0x110a9bc93 <+227>: callq 0x110ba403c ; symbol stub for: strncmp
0x110a9bc98 <+232>: testl %eax, %eax
0x110a9bc9a <+234>: je 0x110a9be63 ; <+691>
0x110a9bca0 <+240>: movq 0x2ca1c1(%rip), %rsi ; "methodSignatureForSelector:"
0x110a9bca7 <+247>: movq %r12, %rdi
0x110a9bcaa <+250>: callq 0x110ba37e4 ; symbol stub for: class_respondsToSelector
0x110a9bcaf <+255>: testb %al, %al
0x110a9bcb1 <+257>: movq -0x40(%rbp), %r14
0x110a9bcb5 <+261>: movq -0x38(%rbp), %r13
0x110a9bcb9 <+265>: je 0x110a9beb4 ; <+772>
0x110a9bcbf <+271>: movq 0x2ca1a2(%rip), %rsi ; "methodSignatureForSelector:"
0x110a9bcc6 <+278>: movq %r14, %rdi
0x110a9bcc9 <+281>: movq -0x30(%rbp), %rdx
0x110a9bccd <+285>: callq *0x2dc525(%rip) ; (void *)0x00000001105d3800: objc_msgSend
0x110a9bcd3 <+291>: movq %rax, %r12
0x110a9bcd6 <+294>: testq %r12, %r12
0x110a9bcd9 <+297>: je 0x110a9bf11 ; <+865>
0x110a9bcdf <+303>: movq 0x2ca152(%rip), %rsi ; "_frameDescriptor"
0x110a9bce6 <+310>: movq %r12, %rdi
0x110a9bce9 <+313>: callq *0x2dc509(%rip) ; (void *)0x00000001105d3800: objc_msgSend
0x110a9bcef <+319>: movq %rax, %rbx
0x110a9bcf2 <+322>: movq (%rbx), %rax
0x110a9bcf5 <+325>: movzwl 0x22(%rax), %eax
0x110a9bcf9 <+329>: shrl $0x6, %eax
0x110a9bcfc <+332>: andq $0x1, %rax
0x110a9bd00 <+336>: cmpq %r13, %rax
0x110a9bd03 <+339>: je 0x110a9bd49 ; <+409>
0x110a9bd05 <+341>: movq -0x30(%rbp), %rdi
0x110a9bd09 <+345>: callq 0x110ba38ec ; symbol stub for: sel_getName
0x110a9bd0e <+350>: movq %rax, %rdx
0x110a9bd11 <+353>: movq (%rbx), %rax
0x110a9bd14 <+356>: movzwl 0x22(%rax), %eax
0x110a9bd18 <+360>: leaq 0x29b169(%rip), %rsi ; ""
0x110a9bd1f <+367>: leaq 0x2aa161(%rip), %r8 ; " not"
0x110a9bd26 <+374>: testb $0x40, %al
0x110a9bd28 <+376>: movq %r8, %rcx
0x110a9bd2b <+379>: cmovneq %rsi, %rcx
0x110a9bd2f <+383>: testq %r13, %r13
0x110a9bd32 <+386>: cmovneq %rsi, %r8
0x110a9bd36 <+390>: leaq 0x2f1983(%rip), %rsi ; #"*** NSForwarding: warning: method signature and compiler disagree on struct-return-edness of '%s'. Signature thinks it does%s return a struct, and compiler thinks it does%s."
0x110a9bd3d <+397>: movl $0x4, %edi
0x110a9bd42 <+402>: xorl %eax, %eax
Profiler stops in this place without zombie sign.
How to localize NSZombie in source code?
This app work fine on iOS 7 simulator without any issue. But when I'm debugging it on iOS 8.1 simulator it crashes. It would not even reach 1st view controller's viewDidLoad.
Just after compiler leaves applicaitondidFinishLaunchingWithOptions: method app crashes.
However I can run already built app in iOS 8.1 simulator without any issue. Crashes only when I'm running the app through Xcode. What could be the reason? (considering the fact that it's already debugging fine in iOS 7) ?
EDIT: (CRASH LOG)
UIKit`UIApplicationMain:
0x108ecff1e: pushq %rbp
0x108ecff1f: movq %rsp, %rbp
0x108ecff22: pushq %r15
0x108ecff24: pushq %r14
0x108ecff26: pushq %r13
0x108ecff28: pushq %r12
0x108ecff2a: pushq %rbx
0x108ecff2b: subq $0x38, %rsp
0x108ecff2f: movq %rcx, -0x48(%rbp)
0x108ecff33: movq %rdx, %r15
0x108ecff36: movq %rsi, %rbx
0x108ecff39: movl %edi, %r13d
0x108ecff3c: movq 0xb4ca8d(%rip), %rax ; (void *)0x000000010bcf1070: __stack_chk_guard
0x108ecff43: movq (%rax), %rax
0x108ecff46: movq %rax, -0x30(%rbp)
0x108ecff4a: leaq 0xdf66bb(%rip), %r14 ; _UIApplicationLinkedOnVersion
0x108ecff51: movl (%r14), %ecx
0x108ecff54: testl %ecx, %ecx
0x108ecff56: jne 0x108ecff7a ; UIApplicationMain + 92
0x108ecff58: xorl %eax, %eax
0x108ecff5a: cmpq $-0x1, 0xdf05ee(%rip) ; WebKitSetIsClassic + 7
0x108ecff62: je 0x108ecffa9 ; UIApplicationMain + 139
0x108ecff64: leaq 0xdf05e5(%rip), %rdi ; _UIApplicationLinkedOnVersionOnce
0x108ecff6b: leaq 0xb4fcfe(%rip), %rsi ; __block_literal_global1030
0x108ecff72: callq 0x1096a29e4 ; symbol stub for: dispatch_once
0x108ecff77: movl (%r14), %ecx
0x108ecff7a: xorl %eax, %eax
0x108ecff7c: cmpl $0x20100, %ecx
0x108ecff82: jb 0x108ecffa9 ; UIApplicationMain + 139
0x108ecff84: movq 0xdb8e15(%rip), %rdi ; (void *)0x000000010a4d7da8: NSAutoreleasePool
0x108ecff8b: movq 0xd8d406(%rip), %rsi ; "alloc"
0x108ecff92: movq 0xb4d0f7(%rip), %r14 ; (void *)0x000000010a881000: objc_msgSend
0x108ecff99: callq *%r14
0x108ecff9c: movq 0xd8d84d(%rip), %rsi ; "init"
0x108ecffa3: movq %rax, %rdi
0x108ecffa6: callq *%r14
0x108ecffa9: movq %r15, -0x50(%rbp)
0x108ecffad: movq %rax, -0x58(%rbp)
0x108ecffb1: cmpl $0x2, %r13d
0x108ecffb5: jl 0x108ed0019 ; UIApplicationMain + 251
0x108ecffb7: addq $0x8, %rbx
0x108ecffbb: decl %r13d
0x108ecffbe: leaq 0x8a9075(%rip), %r14 ; "-BuildDefaultPNG"
0x108ecffc5: leaq 0x8a907f(%rip), %r15 ; "-RegisterForSystemEvents"
0x108ecffcc: movq (%rbx), %r12
0x108ecffcf: movq %r12, %rdi
0x108ecffd2: movq %r14, %rsi
0x108ecffd5: callq 0x1096a2cd8 ; symbol stub for: strcmp
0x108ecffda: testl %eax, %eax
0x108ecffdc: je 0x108ed0009 ; UIApplicationMain + 235
0x108ecffde: movq %r12, %rdi
0x108ecffe1: movq %r15, %rsi
0x108ecffe4: callq 0x1096a2cd8 ; symbol stub for: strcmp
0x108ecffe9: testl %eax, %eax
0x108ecffeb: je 0x108ed0000 ; UIApplicationMain + 226
0x108ecffed: movq %r12, %rdi
0x108ecfff0: leaq 0x8a906d(%rip), %rsi ; "--RegisterForSystemEvents"
0x108ecfff7: callq 0x1096a2cd8 ; symbol stub for: strcmp
0x108ecfffc: testl %eax, %eax
0x108ecfffe: jne 0x108ed0010 ; UIApplicationMain + 242
0x108ed0000: movb $0x1, 0xdf656c(%rip) ; __ShouldLaunchSafe
0x108ed0007: jmp 0x108ed0010 ; UIApplicationMain + 242
0x108ed0009: movb $0x1, 0xdf6561(%rip) ; __IsRunningTests
0x108ed0010: addq $0x8, %rbx
0x108ed0014: decl %r13d
0x108ed0017: jne 0x108ecffcc ; UIApplicationMain + 174
0x108ed0019: xorl %eax, %eax
0x108ed001b: callq 0x1096a1592 ; symbol stub for: BKSDisplayServicesStart
0x108ed0020: callq 0x108ed0d0b ; UIApplicationInitialize
0x108ed0025: movq 0xdb8d24(%rip), %rdi ; (void *)0x0000000109c9ec80: UIApplication
0x108ed002c: movq 0xd8d39d(%rip), %rsi ; "class"
0x108ed0033: callq *0xb4d057(%rip) ; (void *)0x000000010a881000: objc_msgSend
0x108ed0039: movq %rax, %r15
0x108ed003c: movq -0x50(%rbp), %rbx
0x108ed0040: testq %rbx, %rbx
0x108ed0043: jne 0x108ed0081 ; UIApplicationMain + 355
0x108ed0045: movq 0xdb8d34(%rip), %rdi ; (void *)0x000000010a4d7e20: NSBundle
0x108ed004c: movq 0xd8e0dd(%rip), %rsi ; "mainBundle"
0x108ed0053: movq 0xb4d036(%rip), %r14 ; (void *)0x000000010a881000: objc_msgSend
0x108ed005a: callq *%r14
0x108ed005d: movq 0xd8e0d4(%rip), %rsi ; "infoDictionary"
0x108ed0064: movq %rax, %rdi
0x108ed0067: callq *%r14
0x108ed006a: movq 0xd8d38f(%rip), %rsi ; "objectForKey:"
0x108ed0071: leaq 0xb8b4b8(%rip), %rdx ; #"NSPrincipalClass"
0x108ed0078: movq %rax, %rdi
0x108ed007b: callq *%r14
0x108ed007e: movq %rax, %rbx
0x108ed0081: movq 0xd8e0c0(%rip), %rsi ; "length"
0x108ed0088: movq %rbx, %rdi
0x108ed008b: callq *0xb4cfff(%rip) ; (void *)0x000000010a881000: objc_msgSend
0x108ed0091: testq %rax, %rax
0x108ed0094: movq -0x48(%rbp), %r13
0x108ed0098: je 0x108ed0127 ; UIApplicationMain + 521
0x108ed009e: movq %rbx, %rdi
0x108ed00a1: callq 0x1096a19ca ; symbol stub for: NSClassFromString
0x108ed00a6: movq %rax, %r15
0x108ed00a9: testq %r15, %r15
0x108ed00ac: jne 0x108ed0127 ; UIApplicationMain + 521
0x108ed00ae: movq 0xdb8b33(%rip), %rdi ; (void *)0x000000010a4d8500: NSAssertionHandler
0x108ed00b5: movq 0xd8d47c(%rip), %rsi ; "currentHandler"
0x108ed00bc: movq 0xb4cfcd(%rip), %r12 ; (void *)0x000000010a881000: objc_msgSend
0x108ed00c3: callq *%r12
0x108ed00c6: movq %rax, -0x50(%rbp)
0x108ed00ca: movq 0xdb8b1f(%rip), %rdi ; (void *)0x000000010a4dae90: NSString
0x108ed00d1: movq 0xd8d468(%rip), %rsi ; "stringWithUTF8String:"
0x108ed00d8: leaq 0x8a8fb0(%rip), %rdx ; "int UIApplicationMain(int, char **, NSString *, NSString *)"
0x108ed00df: callq *%r12
0x108ed00e2: movq %rax, %r14
0x108ed00e5: movq 0xdb8b04(%rip), %rdi ; (void *)0x000000010a4dae90: NSString
0x108ed00ec: movq 0xd8d44d(%rip), %rsi ; "stringWithUTF8String:"
0x108ed00f3: leaq 0x8a868f(%rip), %rdx ; "/SourceCache/UIKit_Sim/UIKit-3318.16.14/UIApplication.m"
0x108ed00fa: callq *%r12
0x108ed00fd: movq %rax, %rcx
0x108ed0100: movq 0xd8e179(%rip), %rsi ; "handleFailureInFunction:file:lineNumber:description:"
0x108ed0107: movq %rbx, (%rsp)
0x108ed010b: leaq 0xb8b43e(%rip), %r9 ; #"Unable to instantiate the UIApplication subclass instance. No class named %# is loaded."
0x108ed0112: xorl %r15d, %r15d
0x108ed0115: movl $0xb36, %r8d
0x108ed011b: xorl %eax, %eax
0x108ed011d: movq %r14, %rdx
0x108ed0120: movq -0x50(%rbp), %rdi
0x108ed0124: callq *%r12
0x108ed0127: leaq 0x330(%rip), %rdi ; _UIApplicationHandleEvent
0x108ed012e: callq 0x1096a1d12 ; symbol stub for: GSEventRegisterEventCallBack
0x108ed0133: leaq 0x8f1(%rip), %rdi ; _UIApplicationHandleHIDEvent
0x108ed013a: callq 0x1096a15bc ; symbol stub for: BKSHIDEventRegisterEventCallback
0x108ed013f: movq 0xd8d28a(%rip), %rsi ; "class"
0x108ed0146: movq 0xb4cf43(%rip), %r12 ; (void *)0x000000010a881000: objc_msgSend
0x108ed014d: movq %r15, %rdi
0x108ed0150: callq *%r12
0x108ed0153: movq 0xd8e196(%rip), %rsi ; "registerAsSystemApp"
0x108ed015a: movq %rax, %rdi
0x108ed015d: callq *%r12
0x108ed0160: movb %al, 0xdf640d(%rip) ; __RegisterAsSystemApp
0x108ed0166: cmpq $-0x1, 0xdf0372(%rip) ; __signalRunLoopSource + 7
0x108ed016e: jne 0x108ed0446 ; UIApplicationMain + 1320
0x108ed0174: cmpb $0x0, 0xdf036d(%rip) ; _UIApplicationIsExtension.once + 7
0x108ed017b: je 0x108ed0186 ; UIApplicationMain + 616
0x108ed017d: xorl %eax, %eax
0x108ed017f: callq 0x1096a1cee ; symbol stub for: GSEventInitializeAsExtension
0x108ed0184: jmp 0x108ed0192 ; UIApplicationMain + 628
0x108ed0186: movzbl 0xdf63e6(%rip), %edi ; __RegisterAsSystemApp
0x108ed018d: callq 0x1096a1ce8 ; symbol stub for: GSEventInitialize
0x108ed0192: movq 0xb4cca7(%rip), %rax ; (void *)0x000000010ae3f300: NSDefaultRunLoopMode
0x108ed0199: movq (%rax), %rdi
0x108ed019c: callq 0x1096a1d06 ; symbol stub for: GSEventPushRunLoopMode
0x108ed01a1: movq 0xd8e430(%rip), %rsi ; "_startWindowServerIfNecessary"
0x108ed01a8: movq %r15, %rdi
0x108ed01ab: callq *%r12
0x108ed01ae: movq 0xd8e42b(%rip), %rsi ; "_startStatusBarServerIfNecessary"
0x108ed01b5: movq %r15, %rdi
0x108ed01b8: callq *%r12
0x108ed01bb: movq %r15, %rdi
0x108ed01be: callq 0x108ecfdd0 ; UIApplicationInstantiateSingleton
0x108ed01c3: movq 0xdb8c56(%rip), %rdi ; (void *)0x000000010e867498: FBSUIApplicationSystemService
0x108ed01ca: movq 0xd8d1c7(%rip), %rsi ; "alloc"
0x108ed01d1: callq *%r12
0x108ed01d4: movq 0xd8e40d(%rip), %rsi ; "initWithQueue:"
0x108ed01db: movq 0xb4c7fe(%rip), %rdx ; (void *)0x000000010bbe4780: _dispatch_main_q
0x108ed01e2: movq %rax, %rdi
0x108ed01e5: callq *%r12
0x108ed01e8: movq %rax, 0xdf0319(%rip) ; __systemAppService
0x108ed01ef: movq 0xdf6372(%rip), %rdx ; UIApp
0x108ed01f6: movq 0xd8d48b(%rip), %rsi ; "setDelegate:"
0x108ed01fd: movq %rax, %rdi
0x108ed0200: callq *%r12
0x108ed0203: movq 0xdb8c1e(%rip), %rdi ; (void *)0x000000010e867650: FBSUIApplicationWorkspace
0x108ed020a: movq 0xd8d187(%rip), %rsi ; "alloc"
0x108ed0211: callq *%r12
0x108ed0214: movq %rax, %r14
0x108ed0217: movq 0xdb8c12(%rip), %rbx ; (void *)0x000000010e868168: FBSSerialQueue
0x108ed021e: movq 0xb4cc13(%rip), %rax ; (void *)0x000000010ae3f308: NSRunLoopCommonModes
0x108ed0225: movq (%rax), %rax
0x108ed0228: movq %rax, -0x40(%rbp)
0x108ed022c: leaq 0xb8d9dd(%rip), %rax ; #"UIInitializationRunLoopMode"
0x108ed0233: movq %rax, -0x38(%rbp)
0x108ed0237: movq 0xdb897a(%rip), %rdi ; (void *)0x000000010ae78cd8: NSArray
0x108ed023e: movq 0xd8d0fb(%rip), %rsi ; "arrayWithObjects:count:"
0x108ed0245: leaq -0x40(%rbp), %rdx
0x108ed0249: movl $0x2, %ecx
0x108ed024e: callq *%r12
0x108ed0251: movq 0xd8e398(%rip), %rsi ; "queueWithMainRunLoopModes:"
0x108ed0258: movq %rbx, %rdi
0x108ed025b: movq %rax, %rdx
0x108ed025e: callq *%r12
0x108ed0261: movq 0xd8e390(%rip), %rsi ; "initWithSerialQueue:"
0x108ed0268: movq %r14, %rdi
0x108ed026b: movq %rax, %rdx
0x108ed026e: callq *%r12
0x108ed0271: movq %rax, 0xdf0238(%rip) ; __workspace
0x108ed0278: movq 0xdf62e9(%rip), %rdx ; UIApp
0x108ed027f: movq 0xd8d402(%rip), %rsi ; "setDelegate:"
0x108ed0286: movq %rax, %rdi
0x108ed0289: callq *%r12
0x108ed028c: movq 0xdb8965(%rip), %rdi ; (void *)0x0000000109ca4540: UIDevice
0x108ed0293: movq 0xd8d2d6(%rip), %rsi ; "currentDevice"
0x108ed029a: callq *%r12
0x108ed029d: movq 0xd8d2d4(%rip), %rsi ; "userInterfaceIdiom"
0x108ed02a4: movq %rax, %rdi
0x108ed02a7: callq *%r12
0x108ed02aa: cmpq $0x1, %rax
0x108ed02ae: jne 0x108ed02c4 ; UIApplicationMain + 934
0x108ed02b0: movq 0xdb8af1(%rip), %rdi ; (void *)0x0000000109cab250: UIClassicController
0x108ed02b7: movq 0xd8e062(%rip), %rsi ; "sharedClassicController"
0x108ed02be: callq *0xb4cdcc(%rip) ; (void *)0x000000010a881000: objc_msgSend
0x108ed02c4: testq %r13, %r13
0x108ed02c7: jne 0x108ed0307 ; UIApplicationMain + 1001
0x108ed02c9: movq 0xdb8ab0(%rip), %rdi ; (void *)0x000000010a4d7e20: NSBundle
0x108ed02d0: movq 0xd8de59(%rip), %rsi ; "mainBundle"
0x108ed02d7: callq *%r12
0x108ed02da: movq 0xd8de57(%rip), %rsi ; "infoDictionary"
0x108ed02e1: movq %rax, %rdi
0x108ed02e4: callq *%r12
0x108ed02e7: movq 0xd8d112(%rip), %rsi ; "objectForKey:"
0x108ed02ee: leaq 0xb8b27b(%rip), %rdx ; #"UIApplicationDelegateClass"
0x108ed02f5: movq %rax, %rdi
0x108ed02f8: callq *%r12
0x108ed02fb: movq %rax, %r13
0x108ed02fe: testq %r13, %r13
0x108ed0301: je 0x108ed0401 ; UIApplicationMain + 1251
0x108ed0307: movq %r13, %rdi
0x108ed030a: callq 0x1096a19ca ; symbol stub for: NSClassFromString
0x108ed030f: movq %rax, %r14
0x108ed0312: testq %r14, %r14
0x108ed0315: jne 0x108ed0384 ; UIApplicationMain + 1126
0x108ed0317: movq 0xdb88ca(%rip), %rdi ; (void *)0x000000010a4d8500: NSAssertionHandler
0x108ed031e: movq 0xd8d213(%rip), %rsi ; "currentHandler"
0x108ed0325: callq *%r12
0x108ed0328: movq %rax, %r15
0x108ed032b: movq 0xdb88be(%rip), %rdi ; (void *)0x000000010a4dae90: NSString
0x108ed0332: movq 0xd8d207(%rip), %rsi ; "stringWithUTF8String:"
0x108ed0339: leaq 0x8a8d4f(%rip), %rdx ; "int UIApplicationMain(int, char **, NSString *, NSString *)"
0x108ed0340: callq *%r12
0x108ed0343: movq %rax, %rbx
0x108ed0346: movq 0xdb88a3(%rip), %rdi ; (void *)0x000000010a4dae90: NSString
0x108ed034d: movq 0xd8d1ec(%rip), %rsi ; "stringWithUTF8String:"
0x108ed0354: leaq 0x8a842e(%rip), %rdx ; "/SourceCache/UIKit_Sim/UIKit-3318.16.14/UIApplication.m"
0x108ed035b: callq *%r12
0x108ed035e: movq %rax, %rcx
0x108ed0361: movq 0xd8df18(%rip), %rsi ; "handleFailureInFunction:file:lineNumber:description:"
0x108ed0368: movq %r13, (%rsp)
0x108ed036c: leaq 0xb8b21d(%rip), %r9 ; #"Unable to instantiate the UIApplication delegate instance. No class named %# is loaded."
0x108ed0373: movl $0xb62, %r8d
0x108ed0379: xorl %eax, %eax
0x108ed037b: movq %rbx, %rdx
0x108ed037e: movq %r15, %rdi
0x108ed0381: callq *%r12
0x108ed0384: movq 0xdb89c5(%rip), %rdi ; (void *)0x0000000109c9ec80: UIApplication
0x108ed038b: movq 0xd8d03e(%rip), %rsi ; "class"
0x108ed0392: callq *%r12
0x108ed0395: movq 0xd8e264(%rip), %rsi ; "isSubclassOfClass:"
0x108ed039c: movq %r14, %rdi
0x108ed039f: movq %rax, %rdx
0x108ed03a2: callq *%r12
0x108ed03a5: movq 0xdf61bc(%rip), %rbx ; UIApp
0x108ed03ac: testb %al, %al
0x108ed03ae: je 0x108ed03c5 ; UIApplicationMain + 1191
0x108ed03b0: movq 0xd8d2d1(%rip), %rsi ; "setDelegate:"
0x108ed03b7: movq %rbx, %rdi
0x108ed03ba: movq %rbx, %rdx
0x108ed03bd: callq *0xb4cccd(%rip) ; (void *)0x000000010a881000: objc_msgSend
0x108ed03c3: jmp 0x108ed0401 ; UIApplicationMain + 1251
0x108ed03c5: movq 0xd8cfcc(%rip), %rsi ; "alloc"
0x108ed03cc: movq %r14, %rdi
0x108ed03cf: callq *%r12
0x108ed03d2: movq 0xd8d417(%rip), %rsi ; "init"
0x108ed03d9: movq %rax, %rdi
0x108ed03dc: callq *%r12
0x108ed03df: movq 0xd8d4d2(%rip), %rsi ; "autorelease"
0x108ed03e6: movq %rax, %rdi
0x108ed03e9: callq *%r12
0x108ed03ec: movq 0xd8e215(%rip), %rsi ; "_setDelegate:assumeOwnership:"
0x108ed03f3: movl $0x1, %ecx
0x108ed03f8: movq %rbx, %rdi
0x108ed03fb: movq %rax, %rdx
0x108ed03fe: callq *%r12
0x108ed0401: movq 0xd8cf78(%rip), %rsi ; "release"
0x108ed0408: movq -0x58(%rbp), %rdi
0x108ed040c: callq *%r12
0x108ed040f: movq 0xdf6152(%rip), %rdi ; UIApp
0x108ed0416: movq 0xd8e1f3(%rip), %rsi ; "_run"
0x108ed041d: callq *%r12
0x108ed0420: movq 0xb4c5a9(%rip), %rax ; (void *)0x000000010bcf1070: __stack_chk_guard
0x108ed0427: movq (%rax), %rax
0x108ed042a: cmpq -0x30(%rbp), %rax
0x108ed042e: jne 0x108ed0441 ; UIApplicationMain + 1315
0x108ed0430: xorl %eax, %eax
0x108ed0432: addq $0x38, %rsp
0x108ed0436: popq %rbx
0x108ed0437: popq %r12
0x108ed0439: popq %r13
0x108ed043b: popq %r14
0x108ed043d: popq %r15
0x108ed043f: popq %rbp
0x108ed0440: retq
0x108ed0441: callq 0x1096a2936 ; symbol stub for: __stack_chk_fail
0x108ed0446: leaq 0xdf0093(%rip), %rdi ; _UIApplicationIsExtension.once
0x108ed044d: leaq 0xb4f57c(%rip), %rsi ; __block_literal_global616
0x108ed0454: callq 0x1096a29e4 ; symbol stub for: dispatch_once
0x108ed0459: jmp 0x108ed0174 ; UIApplicationMain + 598
breakpoint stops near :
0x108ed0420: movq 0xb4c5a9(%rip), %rax ; (void *)0x000000010bcf1070: __stack_chk_guard
I'm working with xcode 6.3 and swift 1.2. It seems that there is a problem with the pod that you've imported. Try to update the pod installed, then restart xcode and try again. It worked for me :)
I'm debugging a random SIGTRAP crash right now that just happens in the background. It's probably something that has to do with an NSManagedObjectContext somewhere.
Besides that, I'm trying to debug it using an exception breakpoint to at least find out where it's originating from. The only problem is that the crash/breakpoint occurs in a 0 objc_exception_throw, which is no help to me.
The data I get back looks like this:
libobjc.A.dylib`objc_exception_throw:
0x32a3a960: push {r4, r5, r6, r7, lr} // breakpoint stops here
0x32a3a962: add r7, sp, #12
0x32a3a964: mov r4, r0
0x32a3a966: movs r0, #16
0x32a3a968: blx 0x32a46854 ; symbol stub for: -[NSObject isEqual:]
So my question is, how I can I create an exception breakpoint to initiate itself earlier? I'm trying to make the breakpoint occur in the last bit of actual Objective-C code before the crash.
I have tried editing the breakpoint to be shared, break on throw, then break on catch, and have changed the type of exception between Objective-C, C++, and "all" with no luck.
How can I make the exception breakpoint throw earlier?
Unless there is a way to decipher the code I posted. If that's possible, please give me a brief explanation of what it means, and how you deciphered it so I can learn to do so as well :)
Thanks everyone!
If I let the program run...
It continues to the crash, which looks like this:
libsystem_kernel.dylib`mach_msg_trap:
0x30830ea0: mov r12, sp
0x30830ea4: push {r4, r5, r6, r8}
0x30830ea8: ldm r12, {r4, r5, r6}
0x30830eac: mvn r12, #30
0x30830eb0: svc #128
0x30830eb4: pop {r4, r5, r6, r8} // SIGTRAP throws here
0x30830eb8: bx lr
Stack trace when running command "bt" as a debugger command
* thread #13: tid = 0x2337, 0x32a3a960 libobjc.A.dylib`objc_exception_throw, stop reason = breakpoint 1.1
frame #0: 0x32a3a960 libobjc.A.dylib`objc_exception_throw
frame #1: 0x340f9fee CoreData`-[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 298
frame #2: 0x341522d2 CoreData`-[NSManagedObjectContext save:] + 730
frame #3: 0x32054b02 UIKit`__84-[UIManagedDocument writeContents:toURL:forSaveOperation:originalContentsURL:error:]_block_invoke_0 + 30
frame #4: 0x34155bc0 CoreData`developerSubmittedBlockToNSManagedObjectContextPerform + 88
frame #5: 0x36e3d4b6 libdispatch.dylib`_dispatch_client_callout + 22
frame #6: 0x36e419f6 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 30
frame #7: 0x34155d42 CoreData`-[NSManagedObjectContext performBlockAndWait:] + 174
frame #8: 0x32054862 UIKit`-[UIManagedDocument writeContents:toURL:forSaveOperation:originalContentsURL:error:] + 986
frame #9: 0x3205418a UIKit`-[UIManagedDocument writeContents:andAttributes:safelyToURL:forSaveOperation:error:] + 698
frame #10: 0x32017ce4 UIKit`__block_global_4 + 68
frame #11: 0x32017c80 UIKit`__block_global_3 + 156
frame #12: 0x339c767c Foundation`-[NSFileCoordinator _invokeAccessor:thenCompletionHandler:] + 144
frame #13: 0x339c791e Foundation`__73-[NSFileCoordinator coordinateWritingItemAtURL:options:error:byAccessor:]_block_invoke_0 + 90
frame #14: 0x339c894e Foundation`-[NSFileCoordinator(NSPrivate) _invokeAccessor:orDont:thenRelinquishAccessClaimForID:] + 202
frame #15: 0x339c926c Foundation`-[NSFileCoordinator(NSPrivate) _coordinateWritingItemAtURL:options:error:byAccessor:] + 548
frame #16: 0x339c78be Foundation`-[NSFileCoordinator coordinateWritingItemAtURL:options:error:byAccessor:] + 90
frame #17: 0x32017254 UIKit`-[UIDocument _coordinateWritingItemAtURL:error:byAccessor:] + 720
frame #18: 0x320179a0 UIKit`__59-[UIDocument saveToURL:forSaveOperation:completionHandler:]_block_invoke_0 + 284
frame #19: 0x36e3e11e libdispatch.dylib`_dispatch_call_block_and_release + 10
frame #20: 0x36e41ece libdispatch.dylib`_dispatch_queue_drain$VARIANT$mp + 142
frame #21: 0x36e41dc0 libdispatch.dylib`_dispatch_queue_invoke$VARIANT$mp + 40
frame #22: 0x36e4291c libdispatch.dylib`_dispatch_root_queue_drain + 184
frame #23: 0x36e42ac0 libdispatch.dylib`_dispatch_worker_thread2 + 84
frame #24: 0x33ba7a10 libsystem_c.dylib`_pthread_wqthread + 360
frame #25: 0x33ba78a4 libsystem_c.dylib`start_wqthread + 8
Check out the link that Matt Wilding posted in the comments of his answer!
You don't have much control over where that breakpoint triggers. Once you've hit the breakpoint though, you can use the bt command to print the current stack trace.
EDIT: With the backtrace...
It looks like UIDocument's -saveToURL:forSaveOperation:completionHandler: method is the culprit. I've never used the class before, so I can't help too much. If you're calling that method anywhere in your code (like from a block?), you could also put a breakpoint there, in anticipation of the failure.