I have an old iOS app that's only crashing on Release Mode. It's using some objective-c extensions and I found that under one of the extension, if I removed a line that look something like
self.containerView.addSubview(self.pageViewController.view);
then the app doesn't crash. If this line is commented out, the app doesn't show the subview as expected so it seems like when the sub view loads the app crashes. Interestingly the same line is being executed multiple times in different part of the app to load similar kind of views and none of them crashes except only one page. I tried to replace the data that the view is loading using plist to see if it's a data issue since the same extension is loading other pages fine but no luck. I have also analyzed the crash logs and use exception break point, Zombie and Memory leaks using Instrument and nothing is giving any clue. The app crashes with a breakpoint on first line of AppDelegate function indicating it's crashing outside the main code.
Below is the crash log from the device
Exception Type: EXC_BAD_ACCESS (SIGSEGV)Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000VM Region Info: 0 is not in any region. Bytes before following region: 4302422016 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START---> __TEXT 10071c000-100c04000 [ 5024K] r-x/r-x SM=COW ...art.app/SmartTermination Signal: Segmentation fault: 11Termination Reason: Namespace SIGNAL, Code 0xbTerminating Process: exc handler [1327]Triggered by Thread: 0Thread 0 name: Dispatch queue: com.apple.main-threadThread 0 Crashed:0 libobjc.A.dylib 0x00000001990eb270 object_getMethodImplementation + 681 CoreFoundation 0x0000000184d8f608 _NSIsNSArray + 362 CoreFoundation 0x0000000184d8f608 _NSIsNSArray + 363 CoreFoundation 0x0000000184c779ac -[NSMutableArray addObjectsFromArray:] + 724 UIKitCore 0x0000000187a0fb28 -[UIView+ 16063272 (AdditionalLayoutSupport) _accumulateViewConstraintsIntoArray:] + 925 UIKitCore 0x0000000187a10b14 -[UIView+ 16067348 (AdditionalLayoutSupport) _switchToLayoutEngine:] + 1086 UIKitCore 0x0000000187a10ea4 __57-[UIView+ 16068260 (AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 1847 CoreAutoLayout 0x000000019936f934 -[NSISEngine withBehaviors:performModifications:] + 808 UIKitCore 0x0000000187a10db0 __57-[UIView+ 16068016 (AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 5369 UIKitCore 0x0000000187a10b64 -[UIView+ 16067428 (AdditionalLayoutSupport) _switchToLayoutEngine:] + 18810 UIKitCore 0x0000000187a10ea4 __57-[UIView+ 16068260 (AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 18411 CoreAutoLayout 0x000000019936f934 -[NSISEngine withBehaviors:performModifications:] + 8012 UIKitCore 0x0000000187a10db0 __57-[UIView+ 16068016 (AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 53613 UIKitCore 0x0000000187a10b64 -[UIView+ 16067428 (AdditionalLayoutSupport) _switchToLayoutEngine:] + 18814 UIKitCore 0x0000000187a0fd8c -[UIView+ 16063884 (AdditionalLayoutSupport) _initializeHostedLayoutEngine] + 20815 UIKitCore 0x0000000187a04628 -[UIView+ 16016936 (UIConstraintBasedLayout) _layoutEngine_windowDidChange] + 12416 UIKitCore 0x0000000187aed594 -[UIView+ 16971156 (Internal) _didMoveFromWindow:toWindow:] + 26017 UIKitCore 0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 67218 UIKitCore 0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 67219 UIKitCore 0x0000000187a6dfe8 -[UIScrollView _didMoveFromWindow:toWindow:] + 9220 UIKitCore 0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 67221 UIKitCore 0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 67222 UIKitCore 0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 67223 UIKitCore 0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 67224 UIKitCore 0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 67225 UIKitCore 0x0000000187ae1b78 __45-[UIView+ 16923512 (Hierarchy) _postMovedFromSuperview:]_block_invoke + 13626 CoreAutoLayout 0x000000019936f934 -[NSISEngine withBehaviors:performModifications:] + 8027 UIKitCore 0x0000000187ae1a80 -[UIView+ 16923264 (Hierarchy) _postMovedFromSuperview:] + 77628 UIKitCore 0x0000000187af00d8 -[UIView+ 16982232 (Internal) _addSubview:positioned:relativeTo:] + 213229 UIKitCore 0x0000000187ab0ed0 -[UINavigationTransitionView transition:fromView:toView:] + 60430 UIKitCore 0x0000000186e739f8 -[UINavigationController _startTransition:fromViewController:toViewController:] + 276431 UIKitCore 0x0000000186e73eb0 -[UINavigationController _startDeferredTransitionIfNeeded:] + 87632 UIKitCore 0x0000000186e75230 -[UINavigationController __viewWillLayoutSubviews] + 16433 UIKitCore 0x0000000186e580c8 -[UILayoutContainerView layoutSubviews] + 22434 UIKitCore 0x0000000187af6448 -[UIView+ 17007688 (CALayerDelegate) layoutSublayersOfLayer:] + 246835 QuartzCore 0x0000000187ffbf2c -[CALayer layoutSublayers] + 28836 QuartzCore 0x00000001880024d0 CA::Layer::layout_if_needed+ 1426640 (CA::Transaction*) + 52037 QuartzCore 0x000000018800d820 CA::Layer::layout_and_display_if_needed+ 1472544 (CA::Transaction*) + 14038 QuartzCore 0x0000000187f59160 CA::Context::commit_transaction+ 733536 (CA::Transaction*, double, double*) + 41639 QuartzCore 0x0000000187f83324 CA::Transaction::commit+ 906020 () + 72840 QuartzCore 0x0000000187f845d4 CA::Transaction::observer_callback+ 910804 (__CFRunLoopObserver*, unsigned long, void*) + 9241 CoreFoundation 0x0000000184d0287c __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 3242 CoreFoundation 0x0000000184cfcf50 __CFRunLoopDoObservers + 60443 CoreFoundation 0x0000000184cfd498 __CFRunLoopRun + 96044 CoreFoundation 0x0000000184cfcba0 CFRunLoopRunSpecific + 57245 GraphicsServices 0x000000019ba3a598 GSEventRunModal + 16046 UIKitCore 0x00000001875ec3d8 -[UIApplication _run] + 105247 UIKitCore 0x00000001875f1958 UIApplicationMain + 16448 Smart 0x000000010073fb2c main + 146220 (AppDelegate.swift:85)49 libdyld.dylib 0x00000001849db568 start + 4
Not sure where the segmentation fault is happening and where is the array. Will appreciate any suggestions or directions on this.