Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
350 views
in Technique[技术] by (71.8m points)

xcode - iOS App crashes only on release mode with segmentation fault

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 0x0000000000000000
VM 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/Smart

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [1327]
Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x00000001990eb270 object_getMethodImplementation + 68
1   CoreFoundation                  0x0000000184d8f608 _NSIsNSArray + 36
2   CoreFoundation                  0x0000000184d8f608 _NSIsNSArray + 36
3   CoreFoundation                  0x0000000184c779ac -[NSMutableArray addObjectsFromArray:] + 72
4   UIKitCore                       0x0000000187a0fb28 -[UIView+ 16063272 (AdditionalLayoutSupport) _accumulateViewConstraintsIntoArray:] + 92
5   UIKitCore                       0x0000000187a10b14 -[UIView+ 16067348 (AdditionalLayoutSupport) _switchToLayoutEngine:] + 108
6   UIKitCore                       0x0000000187a10ea4 __57-[UIView+ 16068260 (AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 184
7   CoreAutoLayout                  0x000000019936f934 -[NSISEngine withBehaviors:performModifications:] + 80
8   UIKitCore                       0x0000000187a10db0 __57-[UIView+ 16068016 (AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 536
9   UIKitCore                       0x0000000187a10b64 -[UIView+ 16067428 (AdditionalLayoutSupport) _switchToLayoutEngine:] + 188
10  UIKitCore                       0x0000000187a10ea4 __57-[UIView+ 16068260 (AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 184
11  CoreAutoLayout                  0x000000019936f934 -[NSISEngine withBehaviors:performModifications:] + 80
12  UIKitCore                       0x0000000187a10db0 __57-[UIView+ 16068016 (AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 536
13  UIKitCore                       0x0000000187a10b64 -[UIView+ 16067428 (AdditionalLayoutSupport) _switchToLayoutEngine:] + 188
14  UIKitCore                       0x0000000187a0fd8c -[UIView+ 16063884 (AdditionalLayoutSupport) _initializeHostedLayoutEngine] + 208
15  UIKitCore                       0x0000000187a04628 -[UIView+ 16016936 (UIConstraintBasedLayout) _layoutEngine_windowDidChange] + 124
16  UIKitCore                       0x0000000187aed594 -[UIView+ 16971156 (Internal) _didMoveFromWindow:toWindow:] + 260
17  UIKitCore                       0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 672
18  UIKitCore                       0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 672
19  UIKitCore                       0x0000000187a6dfe8 -[UIScrollView _didMoveFromWindow:toWindow:] + 92
20  UIKitCore                       0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 672
21  UIKitCore                       0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 672
22  UIKitCore                       0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 672
23  UIKitCore                       0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 672
24  UIKitCore                       0x0000000187aed730 -[UIView+ 16971568 (Internal) _didMoveFromWindow:toWindow:] + 672
25  UIKitCore                       0x0000000187ae1b78 __45-[UIView+ 16923512 (Hierarchy) _postMovedFromSuperview:]_block_invoke + 136
26  CoreAutoLayout                  0x000000019936f934 -[NSISEngine withBehaviors:performModifications:] + 80
27  UIKitCore                       0x0000000187ae1a80 -[UIView+ 16923264 (Hierarchy) _postMovedFromSuperview:] + 776
28  UIKitCore                       0x0000000187af00d8 -[UIView+ 16982232 (Internal) _addSubview:positioned:relativeTo:] + 2132
29  UIKitCore                       0x0000000187ab0ed0 -[UINavigationTransitionView transition:fromView:toView:] + 604
30  UIKitCore                       0x0000000186e739f8 -[UINavigationController _startTransition:fromViewController:toViewController:] + 2764
31  UIKitCore                       0x0000000186e73eb0 -[UINavigationController _startDeferredTransitionIfNeeded:] + 876
32  UIKitCore                       0x0000000186e75230 -[UINavigationController __viewWillLayoutSubviews] + 164
33  UIKitCore                       0x0000000186e580c8 -[UILayoutContainerView layoutSubviews] + 224
34  UIKitCore                       0x0000000187af6448 -[UIView+ 17007688 (CALayerDelegate) layoutSublayersOfLayer:] + 2468
35  QuartzCore                      0x0000000187ffbf2c -[CALayer layoutSublayers] + 288
36  QuartzCore                      0x00000001880024d0 CA::Layer::layout_if_needed+ 1426640 (CA::Transaction*) + 520
37  QuartzCore                      0x000000018800d820 CA::Layer::layout_and_display_if_needed+ 1472544 (CA::Transaction*) + 140
38  QuartzCore                      0x0000000187f59160 CA::Context::commit_transaction+ 733536 (CA::Transaction*, double, double*) + 416
39  QuartzCore                      0x0000000187f83324 CA::Transaction::commit+ 906020 () + 728
40  QuartzCore                      0x0000000187f845d4 CA::Transaction::observer_callback+ 910804 (__CFRunLoopObserver*, unsigned long, void*) + 92
41  CoreFoundation                  0x0000000184d0287c __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
42  CoreFoundation                  0x0000000184cfcf50 __CFRunLoopDoObservers + 604
43  CoreFoundation                  0x0000000184cfd498 __CFRunLoopRun + 960
44  CoreFoundation                  0x0000000184cfcba0 CFRunLoopRunSpecific + 572
45  GraphicsServices                0x000000019ba3a598 GSEventRunModal + 160
46  UIKitCore                       0x00000001875ec3d8 -[UIApplication _run] + 1052
47  UIKitCore                       0x00000001875f1958 UIApplicationMain + 164
48  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.

question from:https://stackoverflow.com/questions/65948343/ios-app-crashes-only-on-release-mode-with-segmentation-fault

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...