ios - setRightButton 上的应用程序崩溃。不知道为什么

标签 ios iphone crash crash-reports

我试图找出为什么我的应用程序有时会在客户设备上崩溃。我的应用程序来自AppStore。这种情况并不总是发生,只有在极少数情况下才会出现。

这是使用的代码块

[UIView animateWithDuration:0.3 animations:^(void){ [self.spinner setAlpha:0.0]; } completion:^(BOOL finished){
    if(self.spinner != nil){
    [self.spinner removeFromSuperview];
    self.spinner = nil;
        UIBarButtonItem *externButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(openBrowser)];        
        [self.navigationItem setRightBarButtonItem:externButton animated:YES];
    }
}];

它在 setRightBarButtomItem:animated: 上崩溃。代码块在后台线程中执行。这是问题所在吗?

这里是崩溃日志:

Hardware Model:      iPhone5,2
Process:         [THE APP] [3052]
Path:            (null)
Identifier:      [THE APP]
Version:         3.9.0 (3.9.0)
Code Type:       ARM
Parent Process:  launchd [1]

Date/Time:       2013-11-09 16:07:04.000 +0100
OS Version:      iPhone OS 7.0 (11A465)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x7000000c
Crashed Thread:  13

Thread 0:
0   CoreFoundation                  0x30781224 __CFStringCreateImmutableFunnel3 + 1160
1   CoreFoundation                  0x306dbf38 CFStringCreateWithBytes + 48
2   Foundation                      0x310c49e8 -[NSPlaceholderString initWithBytes:length:encoding:] + 100
3   Foundation                      0x310c4968 +[NSString stringWithUTF8String:] + 124
4   Foundation                      0x310c48b0 NSStringFromClass + 128
5   UIKit                           0x32fddb68 +[_UIAppearanceCustomizableClassInfo _customizableClassInfoForViewClass:withGuideClass:] + 260
6   UIKit                           0x32fddd90 -[_UIAppearanceCustomizableClassInfo _superClassInfo] + 160
7   UIKit                           0x32fddcc8 existingAppearancesNodesInNodeForClassAndSuperclasses + 136
8   UIKit                           0x32fdd1d0 +[_UIAppearance _applyInvocationsTo:window:matchingSelector:] + 164
9   UIKit                           0x32fdd120 +[_UIAppearance _applyInvocationsTo:window:] + 24
10  UIKit                           0x32f32488 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 176
11  QuartzCore                      0x32bb9f40 -[CALayer layoutSublayers] + 140
12  QuartzCore                      0x32bb5760 CA::Layer::layout_if_needed(CA::Transaction*) + 344
13  UIKit                           0x32f47410 -[UIView(Hierarchy) layoutBelowIfNeeded] + 532
14  UIKit                           0x32fe9810 -[UIBarButtonItem(UIStatic) _leftRightImagePaddingForEdgeMarginInNavBarIsMini:] + 360
15  UIKit                           0x32fcf140 -[UINavigationBar _getTitleViewFrame:leftViewFrames:rightViewFrames:forItemAtIndex:returnedIdealWidthOfTextContent:availableLayoutWidthForTextContent:idealBackButtonWidth:] + 2504
16  UIKit                           0x32fc6e38 -[UINavigationBar _getTitleViewFrame:leftViewFrames:rightViewFrames:forItemAtIndex:] + 632
17  UIKit                           0x32fc6bb8 -[UINavigationBar _getTitleViewFrame:leftViewFrames:rightViewFrames:] + 136
18  UIKit                           0x32fcd080 -[UINavigationBar _setLeftViews:rightViews:] + 1248
19  UIKit                           0x32fca2b8 -[UINavigationBar _pushNavigationItem:transition:] + 464
20  UIKit                           0x32fc9e98 __71-[UINavigationController pushViewController:transition:forceImmediate:]_block_invoke + 148
21  UIKit                           0x32fe13a0 -[UINavigationController _startDeferredTransitionIfNeeded:] + 868
22  UIKit                           0x32fe0fe8 -[UINavigationController __viewWillLayoutSubviews] + 44
23  UIKit                           0x32fe0f78 -[UILayoutContainerView layoutSubviews] + 180
24  UIKit                           0x32f32530 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 344
25  QuartzCore                      0x32bb9f40 -[CALayer layoutSublayers] + 140
26  QuartzCore                      0x32bb5760 CA::Layer::layout_if_needed(CA::Transaction*) + 344
27  QuartzCore                      0x32bb55f8 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
28  QuartzCore                      0x32bb5008 CA::Context::commit_transaction(CA::Transaction*) + 224
29  QuartzCore                      0x32bb4e18 CA::Transaction::commit() + 308
30  QuartzCore                      0x32baeb48 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 52
31  CoreFoundation                  0x30777f70 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
32  CoreFoundation                  0x307758f8 __CFRunLoopDoObservers + 280
33  CoreFoundation                  0x30775c48 __CFRunLoopRun + 736
34  CoreFoundation                  0x306e0540 CFRunLoopRunSpecific + 524
35  CoreFoundation                  0x306e0320 CFRunLoopRunInMode + 104
36  GraphicsServices                0x354172e8 GSEventRunModal + 136
37  UIKit                           0x32f971e0 UIApplicationMain + 1132
38  [THE APP]                            0x00059f48 main (main.m:21)

Thread 1:
0   libsystem_kernel.dylib          0x3b043838 kevent64 + 24
1   libdispatch.dylib               0x3af8c640 _dispatch_mgr_thread + 36

Thread 2:
0   libsystem_kernel.dylib          0x3b056c7c __workq_kernreturn + 8

Thread 3:
0   libsystem_kernel.dylib          0x3b056c7c __workq_kernreturn + 8

Thread 4:
0   libsystem_kernel.dylib          0x3b043a84 mach_msg_trap + 20
1   CoreFoundation                  0x30777560 __CFRunLoopServiceMachPort + 156
2   CoreFoundation                  0x30775c80 __CFRunLoopRun + 792
3   CoreFoundation                  0x306e0540 CFRunLoopRunSpecific + 524
4   CoreFoundation                  0x306e0320 CFRunLoopRunInMode + 104
5   Foundation                      0x3111b650 +[NSURLConnection(Loader) _resourceLoadLoop:] + 320
6   Foundation                      0x31190dc0 __NSThread__main__ + 1056
7   libsystem_pthread.dylib         0x3b0bcc58 _pthread_body + 136
8   libsystem_pthread.dylib         0x3b0bcbc8 _pthread_start + 96

Thread 5:
0   libsystem_kernel.dylib          0x3b056c7c __workq_kernreturn + 8

Thread 6:
0   libsystem_kernel.dylib          0x3b056c7c __workq_kernreturn + 8

Thread 7:
0   libsystem_kernel.dylib          0x3b056550 __semwait_signal + 24
1   Foundation                      0x311904d8 +[NSThread sleepForTimeInterval:] + 144
2   [THE APP]                            0x0014a870 -[KSCrashDeadlockMonitor runMonitor] + 232
3   Foundation                      0x31190dc0 __NSThread__main__ + 1056
4   libsystem_pthread.dylib         0x3b0bcc58 _pthread_body + 136
5   libsystem_pthread.dylib         0x3b0bcbc8 _pthread_start + 96

Thread 8:
0   libsystem_kernel.dylib          0x3b043a84 mach_msg_trap + 20
1   [THE APP]                            0x001469e0 ksmachexc_i_handleExceptions + 128
2   libsystem_pthread.dylib         0x3b0bcc58 _pthread_body + 136
3   libsystem_pthread.dylib         0x3b0bcbc8 _pthread_start + 96

Thread 9:

Thread 10:
0   libsystem_kernel.dylib          0x3b056c7c __workq_kernreturn + 8

Thread 11:
0   libsystem_kernel.dylib          0x3b056440 select$DARWIN_EXTSN + 20
1   libsystem_pthread.dylib         0x3b0bcc58 _pthread_body + 136
2   libsystem_pthread.dylib         0x3b0bcbc8 _pthread_start + 96

Thread 12:
0   libsystem_kernel.dylib          0x3b056c7c __workq_kernreturn + 8

Thread 13 Crashed:
0   libobjc.A.dylib                 0x3aaa1b66 objc_msgSend + 6
1   UIKit                           0x32fe4b80 -[UINavigationItem updateNavigationBarButtonsAnimated:] + 156
2   UIKit                           0x32fe46e8 -[UINavigationItem setRightBarButtonItem:animated:] + 156
3   [THE APP]                            0x000c6058 -[ProductViewController loadXML] (ProductViewController.m:978)
4   Foundation                      0x31190dc0 __NSThread__main__ + 1056
5   libsystem_pthread.dylib         0x3b0bcc58 _pthread_body + 136
6   libsystem_pthread.dylib         0x3b0bcbc8 _pthread_start + 96

Thread 13 crashed with ARM Thread State:
    r0: 0x15e78c40     r1: 0x33517435     r2: 0x00000000     r3: 0x00000000 
    r4: 0x33517435     r5: 0x33530ea0     r6: 0x15e83b00     r7: 0x037a2be0 
    r8: 0x15d56570     r9: 0x70000000    r10: 0x00000000    r11: 0x00000001 
    ip: 0x3b5be224     sp: 0x037a27f0     lr: 0x32fccffb     pc: 0x3aaa1b66 
  cpsr: 0x20000030 

Binary Images:
[cut cause of char limit]

有什么想法吗?感谢您的帮助!

最佳答案

首先,您不应该在后台线程中运行它。 其次,当您过度释放某些内容时,通常会发生 BAD_ACCESS。

我不知道你在哪里过度释放,但也许你可以在你的代码中找到它。我的猜测是导航项尝试在设置 externButton 之前释放某些内容...

编辑:这段代码发生在哪里?可能是 UIViewController 不再被推送到导航 Controller 中,或者在执行此代码时不再被推送到顶部 Controller 中?

关于ios - setRightButton 上的应用程序崩溃。不知道为什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19889961/

相关文章:

javascript - 为什么这个 .js 脚本停止工作并导致浏览器卡住?

java - EditText.getText().toString() 崩溃

iOS:在 Instruments 中按下录音时应用程序崩溃

ios - 如何更正 xcode 异常对我的应用所做的更改?

ios - 使用免费 Apple ID 将 Apple iOS Swift App 部署到 iPhone

ios - xcode 9 本地化应用程序问题

ios - 具有自动布局的 iOS 旋转

ios - 意外的 CFBundleExecutable key 问题

ios - 数组或 CGImageRef 的内存泄漏

java - 安卓 : JNI crash