iOS 5 上的应用程序崩溃

Posted

技术标签:

【中文标题】iOS 5 上的应用程序崩溃【英文标题】:App Crash on iOS 5 【发布时间】:2012-02-27 08:37:31 【问题描述】:

我一直在我的应用程序中使用 Mobclix,直到昨天我收到了来自 TestFlight 的崩溃报告,这似乎是由 Mobclix 引起的。我想知道是否有人可以阐明这种情况,或者我如何防止它再次发生。这发生在运行 ios 5.0.1 的 iPhone 4s 上。感谢您的任何意见!

SIGSEGV - Unknown Signal

0 MyApp 0x00136046 testflight_backtrace + 142
1 MyApp 0x00136b60 TFSignalHandler + 212 
2 libsystem_c.dylib 0x35fce538 _sigtramp + 48 
3 CoreFoundation 0x37ab40ba -[__NSCFString isEqualToString:] + 174 
4 QuartzCore 0x332b0b9c -[CALayer actionForKey:] + 76 
5 QuartzCore 0x332b0b18 _ZL12actionForKeyP7CALayerPN2CA11TransactionEP8NSString + 56 
6 QuartzCore 0x332b07c0 _ZN2CA5Layer12begin_changeEPNS_11TransactionEjRP11objc_object + 120 
7 QuartzCore 0x332af8ee _ZN2CA5Layer6setterEj12_CAValueTypePKv + 162 
8 QuartzCore 0x332ddffe -[CALayer setBackgroundColor:] + 34 
9 UIKit 0x34f5dd5c -[UIView(Internal) _setBackgroundCGColor:withSystemColorName:] + 1200 
10 UIKit 0x34f5d80a -[UIView(Hierarchy) _setBackgroundColor:] + 114 
11 MyApp 0x00101e4a -[MobclixAdViewInternal initWithFrame:] (MobclixAdViewInternal.m:79) 
12 MyApp 0x00105e1a -[MobclixAdView setupAdViewWithFrame:] (MobclixAdView.m:72) 
13 MyApp 0x00105fa2 -[MobclixAdView initWithFrame:] (MobclixAdView.m:55) 
14 MyApp 0x000cb550 -[LocationDetailViewController createAdBannerView] (LocationDetailViewController.m:394) 
15 MyApp 0x000c9e0e -[LocationDetailViewController viewDidLoad] (LocationDetailViewController.m:109) 
16 UIKit 0x34f4e7fe -[UIViewController view] + 166 
17 UIKit 0x34f5ac38 -[UIViewController contentScrollView] + 24 
18 UIKit 0x34f5aaa8 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 36 
19 UIKit 0x34f5a98e -[UINavigationController _layoutViewController:] + 34 
20 UIKit 0x34f5a210 -[UINavigationController _startTransition:fromViewController:toViewController:] + 500 
21 UIKit 0x34f59f52 -[UINavigationController _startDeferredTransitionIfNeeded] + 250 
22 UIKit 0x34f4e672 -[UINavigationController pushViewController:transition:forceImmediate:] + 806 
23 UIKit 0x34f4e348 -[UINavigationController pushViewController:animated:] + 36 
24 MyApp 0x000cd7f0 -[LocationsViewController tableView:didSelectRowAtIndexPath:] (LocationsViewController.m:362) 
25 UIKit 0x34fc8564 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 944 
26 UIKit 0x35040ce6 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 158 
27 Foundation 0x31a8e942 __NSFireDelayedPerform + 414 
28 CoreFoundation 0x37b31a62 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14 
29 CoreFoundation 0x37b316c8 __CFRunLoopDoTimer + 364 
30 CoreFoundation 0x37b3029e __CFRunLoopRun + 1206 
31 CoreFoundation 0x37ab34dc CFRunLoopRunSpecific + 300 
32 CoreFoundation 0x37ab33a4 CFRunLoopRunInMode + 104 
33 GraphicsServices 0x37631fcc GSEventRunModal + 156 
34 UIKit 0x34f43742 UIApplicationMain + 1090 
35 MyApp 0x000c6514 main (main.m:17) 
36 MyApp 0x000c4b6f start + 39

我还设法从设备获取了完整的崩溃日志:

Incident Identifier: 83282958-196D-444A-9687-3ABB995142B4
CrashReporter Key:   7468d6d075fbaeaa98a71643a55fdc3f52aed471
Hardware Model:      iPhone4,1
Process:         MyApp [11252]
Path:            /var/mobile/Applications/0F320D6D-52F8-4088-B832-CC7454058932/MyApp.app/MyApp
Identifier:      MyApp
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2012-02-04 21:38:51.450 -0500
OS Version:      iPhone OS 5.0.1 (9A405)
Report Version:  104

Exception Type:  EXC_CRASH (SIGSEGV)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  1

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   UIKit                           0x34f178de 0x34f12000 + 22750
1   QuartzCore                      0x332b0b96 0x332ad000 + 15254
2   QuartzCore                      0x332b0b12 0x332ad000 + 15122
3   QuartzCore                      0x332b07ba 0x332ad000 + 14266
4   QuartzCore                      0x332af8e8 0x332ad000 + 10472
5   QuartzCore                      0x332ddff8 0x332ad000 + 200696
6   UIKit                           0x34f5dd56 0x34f12000 + 310614
7   UIKit                           0x34f5d804 0x34f12000 + 309252
8   MyApp                           0x00101e44 -[MobclixAdViewInternal initWithFrame:] (MobclixAdViewInternal.m:79)
9   MyApp                           0x00105e14 -[MobclixAdView setupAdViewWithFrame:] (MobclixAdView.m:72)
10  MyApp                           0x00105f9c -[MobclixAdView initWithFrame:] (MobclixAdView.m:55)
11  MyApp                           0x000cb54a -[LocationDetailViewController createAdBannerView] (LocationDetailViewController.m:394)
12  MyApp                       0x000c9e08 -[LocationDetailViewController viewDidLoad] (LocationDetailViewController.m:109)
13  UIKit                           0x34f4e7f8 0x34f12000 + 247800
14  UIKit                           0x34f5ac32 0x34f12000 + 298034
15  UIKit                           0x34f5aaa2 0x34f12000 + 297634
16  UIKit                           0x34f5a988 0x34f12000 + 297352
17  UIKit                           0x34f5a20a 0x34f12000 + 295434
18  UIKit                           0x34f59f4c 0x34f12000 + 294732
19  UIKit                           0x34f4e66c 0x34f12000 + 247404
20  UIKit                           0x34f4e342 0x34f12000 + 246594
21  MyApp                       0x000cd7ea -[LocationsViewController tableView:didSelectRowAtIndexPath:] (LocationsViewController.m:362)
22  UIKit                           0x34fc855e 0x34f12000 + 746846
23  UIKit                           0x35040ce0 0x34f12000 + 1240288
24  Foundation                      0x31a8e93c 0x319f3000 + 637244
25  CoreFoundation                  0x37b31a5c 0x37aa4000 + 580188
26  CoreFoundation                  0x37b316c2 0x37aa4000 + 579266
27  CoreFoundation                  0x37b30298 0x37aa4000 + 574104
28  CoreFoundation                  0x37ab34d6 0x37aa4000 + 62678
29  CoreFoundation                  0x37ab339e 0x37aa4000 + 62366
30  GraphicsServices                0x37631fc6 0x3762e000 + 16326
31  UIKit                           0x34f4373c 0x34f12000 + 202556
32  MyApp                           0x000c650e main (main.m:17)
33  MyApp                       0x000c4b68 0xc2000 + 11112

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1 Crashed:
0   libsystem_kernel.dylib          0x333e73b4 0x333e6000 + 5044
1   libdispatch.dylib               0x3781bf74 0x37818000 + 16244
2   libdispatch.dylib               0x3781bc92 0x37818000 + 15506

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib          0x333e7010 0x333e6000 + 4112
1   libsystem_kernel.dylib          0x333e7206 0x333e6000 + 4614
2   CoreFoundation                  0x37b3141c 0x37aa4000 + 578588
3   CoreFoundation                  0x37b30154 0x37aa4000 + 573780
4   CoreFoundation                  0x37ab34d6 0x37aa4000 + 62678
5   CoreFoundation                  0x37ab339e 0x37aa4000 + 62366
6   WebCore                         0x32384128 0x322dc000 + 688424
7   libsystem_c.dylib               0x35f85c16 0x35f76000 + 64534
8   libsystem_c.dylib               0x35f85ad0 0x35f76000 + 64208

Thread 3 name:  com.apple.NSURLConnectionLoader
Thread 3:
0   libsystem_kernel.dylib          0x333e7010 0x333e6000 + 4112
1   libsystem_kernel.dylib          0x333e7206 0x333e6000 + 4614
2   CoreFoundation                  0x37b3141c 0x37aa4000 + 578588
3   CoreFoundation                  0x37b30154 0x37aa4000 + 573780
4   CoreFoundation                  0x37ab34d6 0x37aa4000 + 62678
5   CoreFoundation                  0x37ab339e 0x37aa4000 + 62366
6   Foundation                      0x31a03bc2 0x319f3000 + 68546
7   Foundation                      0x31a03a8a 0x319f3000 + 68234
8   Foundation                      0x31a9759a 0x319f3000 + 673178
9   libsystem_c.dylib               0x35f85c16 0x35f76000 + 64534
10  libsystem_c.dylib               0x35f85ad0 0x35f76000 + 64208

Thread 4:
0   libsystem_kernel.dylib          0x333e7010 0x333e6000 + 4112
1   libsystem_kernel.dylib          0x333e7206 0x333e6000 + 4614
2   CoreFoundation                  0x37b3141c 0x37aa4000 + 578588
3   CoreFoundation                  0x37b30154 0x37aa4000 + 573780
4   CoreFoundation                  0x37ab34d6 0x37aa4000 + 62678
5   CoreFoundation                  0x37ab339e 0x37aa4000 + 62366
6   Foundation                      0x319f7b7e 0x319f3000 + 19326
7   Foundation                      0x31a1152c 0x319f3000 + 124204
8   MyApp                           0x0014a986 0xc2000 + 559494
9   Foundation                      0x31a03a8a 0x319f3000 + 68234
10  Foundation                      0x31a9759a 0x319f3000 + 673178
11  libsystem_c.dylib               0x35f85c16 0x35f76000 + 64534
12  libsystem_c.dylib               0x35f85ad0 0x35f76000 + 64208

Thread 5 name:  com.apple.CFSocket.private
Thread 5:
0   libsystem_kernel.dylib          0x333f7570 0x333e6000 + 71024
1   CoreFoundation                  0x37b3566a 0x37aa4000 + 595562
2   libsystem_c.dylib               0x35f85c16 0x35f76000 + 64534
3   libsystem_c.dylib               0x35f85ad0 0x35f76000 + 64208

Thread 6:
0   libsystem_kernel.dylib          0x333e7010 0x333e6000 + 4112
1   libsystem_kernel.dylib          0x333e7206 0x333e6000 + 4614
2   CoreFoundation                  0x37b3141c 0x37aa4000 + 578588
3   CoreFoundation                  0x37b30154 0x37aa4000 + 573780
4   CoreFoundation                  0x37ab34d6 0x37aa4000 + 62678
5   CoreFoundation                  0x37b30474 0x37aa4000 + 574580
6   MyApp                           0x002791cc +[UA_ASIHTTPRequest runRequests] (UA_ASIHTTPRequest.m:4789)
7   Foundation                      0x31a03a8a 0x319f3000 + 68234
8   Foundation                      0x31a9759a 0x319f3000 + 673178
9   libsystem_c.dylib               0x35f85c16 0x35f76000 + 64534
10  libsystem_c.dylib               0x35f85ad0 0x35f76000 + 64208

Thread 7 name:  NetworkIO
Thread 7:
0   libsystem_kernel.dylib          0x333e7010 0x333e6000 + 4112
1   libsystem_kernel.dylib          0x333e7206 0x333e6000 + 4614
2   CoreFoundation                  0x37b3141c 0x37aa4000 + 578588
3   CoreFoundation                  0x37b30154 0x37aa4000 + 573780
4   CoreFoundation                  0x37ab34d6 0x37aa4000 + 62678
5   CoreFoundation                  0x37ab339e 0x37aa4000 + 62366
6   MapKit                          0x37d1a412 0x37d0c000 + 58386
7   Foundation                      0x31a03a8a 0x319f3000 + 68234
8   Foundation                      0x31a9759a 0x319f3000 + 673178
9   libsystem_c.dylib               0x35f85c16 0x35f76000 + 64534
10  libsystem_c.dylib               0x35f85ad0 0x35f76000 + 64208

Thread 8:
0   libsystem_kernel.dylib          0x333f7cd4 0x333e6000 + 72916
1   libsystem_c.dylib               0x35f8030a 0x35f76000 + 41738
2   libsystem_c.dylib               0x35f8009c 0x35f76000 + 41116

Thread 9 name:  WebCore: CFNetwork Loader
Thread 9:
0   libsystem_kernel.dylib          0x333e7010 0x333e6000 + 4112
1   libsystem_kernel.dylib          0x333e7206 0x333e6000 + 4614
2   CoreFoundation                  0x37b3141c 0x37aa4000 + 578588
3   CoreFoundation                  0x37b30154 0x37aa4000 + 573780
4   CoreFoundation                  0x37ab34d6 0x37aa4000 + 62678
5   CoreFoundation                  0x37ab339e 0x37aa4000 + 62366
6   WebCore                         0x323ad69e 0x322dc000 + 857758
7   libsystem_c.dylib               0x35f85c16 0x35f76000 + 64534
8   libsystem_c.dylib               0x35f85ad0 0x35f76000 + 64208

Thread 10:
0   libsystem_kernel.dylib          0x333f7cd4 0x333e6000 + 72916
1   libsystem_c.dylib               0x35f8030a 0x35f76000 + 41738
2   libsystem_c.dylib               0x35f8009c 0x35f76000 + 41116

Thread 11:
0   libsystem_kernel.dylib          0x333f7cd4 0x333e6000 + 72916
1   libsystem_c.dylib               0x35f8030a 0x35f76000 + 41738
2   libsystem_c.dylib               0x35f8009c 0x35f76000 + 41116

Thread 12:
0   libsystem_c.dylib               0x35f79254 0x35f76000 + 12884
1   QuartzCore                      0x332af188 0x332ad000 + 8584
2   QuartzCore                      0x332b2ed8 0x332ad000 + 24280
3   QuartzCore                      0x332b7114 0x332ad000 + 41236
4   QuartzCore                      0x332b6e50 0x332ad000 + 40528
5   QuartzCore                      0x332aed7e 0x332ad000 + 7550
6   CoreFoundation                  0x37b31b44 0x37aa4000 + 580420
7   CoreFoundation                  0x37b2fd80 0x37aa4000 + 572800
8   CoreFoundation                  0x37ab34f2 0x37aa4000 + 62706
9   CoreFoundation                  0x37ab339e 0x37aa4000 + 62366
10  Foundation                      0x319f7b7e 0x319f3000 + 19326
11  MyApp                       0x0025d5cc -[DynamoDBWebServiceClient invoke:rawRequest:unmarshallerDelegate:] (DynamoDBWebServiceClient.m:105)
12  MyApp                       0x0025cb28 -[AmazonDynamoDBClient query:] (AmazonDynamoDBClient.m:55)
13  MyApp                           0x000fb2f6 -[MessageManager loadRecentMessagesForLocation:] (MessageManager.m:99)
14  MyApp                           0x000ca2cc -[LocationDetailViewController loadServerData] (LocationDetailViewController.m:181)
15  Foundation                      0x31a03a8a 0x319f3000 + 68234
16  Foundation                      0x31a9759a 0x319f3000 + 673178
17  libsystem_c.dylib               0x35f85c16 0x35f76000 + 64534
18  libsystem_c.dylib               0x35f85ad0 0x35f76000 + 64208

Thread 1 crashed with ARM Thread State:
    r0: 0x00000004    r1: 0x00000000      r2: 0x00000000      r3: 0x2ff9c634
    r4: 0x00000001    r5: 0x2ff9c750      r6: 0x2ff9c750      r7: 0x2ff9c770
    r8: 0x00000000    r9: 0x00000000     r10: 0x3f44e850     r11: 0x00000000
    ip: 0x0000016b    sp: 0x2ff9c620      lr: 0x3781bf7b      pc: 0x333e73b4
  cpsr: 0x60000010

这里是 Mobclix 相关的所有方法和来自 LocationDetailViewController 的调用:

- (void)adViewDidFinishLoad:(MobclixAdView*)adView 

    if (!adBannerViewIsVisible)  

        // Show the ad banner
        adBannerViewIsVisible = YES;
        [self fixupAdView];
    


- (void)adView:(MobclixAdView*)adView didFailLoadWithError:(NSError*)error 

    if (adBannerViewIsVisible) 

        // Hide the ad banner
        adBannerViewIsVisible = NO;
        [self fixupAdView];
    


- (void)createAdBannerView 

    // Create the ad banner
    self.adBannerView = [[MobclixAdViewiPhone_320x50 alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 50.0f)];

    self.adBannerView.delegate = self;

    [self.view addSubview:adBannerView];


- (void)fixupAdView 

    if (adBannerView != nil)   

        [UIView beginAnimations:@"fixupViews" context:nil];

        // Move items to fit ad banner
        if (adBannerViewIsVisible) 

            CGRect adBannerViewFrame = [adBannerView frame];
            adBannerViewFrame.origin.x = 0;
            adBannerViewFrame.origin.y = 0;
            [adBannerView setFrame:adBannerViewFrame];

            CGRect contentViewFrame = contentView.frame;
            contentViewFrame.origin.y = 50;
            contentViewFrame.size.height = self.view.frame.size.height - 50;
            contentView.frame = contentViewFrame;

            CGRect tableViewFrame = tableView.frame;
            tableViewFrame.origin.y = tableView.frame.origin.y;
            tableViewFrame.size.height = 317;
            tableView.frame = tableViewFrame;

            // Move items to hide ad banner
         else 

            CGRect adBannerViewFrame = [adBannerView frame];
            adBannerViewFrame.origin.x = 0;
            adBannerViewFrame.origin.y = -50;
            [adBannerView setFrame:adBannerViewFrame];

            CGRect contentViewFrame = contentView.frame;
            contentViewFrame.origin.y = 0;
            contentViewFrame.size.height = self.view.frame.size.height;
            contentView.frame = contentViewFrame;  

            CGRect tableViewFrame = tableView.frame;
            tableViewFrame.origin.y = tableView.frame.origin.y;
            tableViewFrame.size.height = 367;
            tableView.frame = tableViewFrame;
        

        [UIView commitAnimations];
       


- (void)viewDidLoad 

    [super viewDidLoad];

    // Attempt to load an ad and resize the view to fit it
    [self createAdBannerView];
    [self fixupAdView];


- (void)viewDidUnload 

    [super viewDidUnload];

    [self.adBannerView cancelAd];
    self.adBannerView.delegate = nil;
    self.adBannerView = nil;


- (void)viewDidAppear:(BOOL)animated 

    [super viewDidAppear:animated];

    // Resume ad loading from Mobclix
    [self.adBannerView resumeAdAutoRefresh];


- (void)viewWillDisappear:(BOOL)animated 

    [super viewWillDisappear:animated];

    // Pause ad loading from Mobclix
    [self.adBannerView pauseAdAutoRefresh];

【问题讨论】:

抱歉,忘记包含了。我将它添加到崩溃日志的顶部。 请贴出方法createAdBannerView(LocationDetailViewController)的实现和相关的Mobclix代码 【参考方案1】:

崩溃的线程 1 只有 Apple 框架调用,没有来自您的应用程序。如果符号化脚本具有可通过 Spotlight 访问的 iOS 5.0.1 符号,则这些符号化。到目前为止,这个问题似乎不太可能与 Mobclix 代码有关。

由于异常类型是 SIGSEGV,您不会在导致崩溃的崩溃线程中找到行号。您的代码中有某个地方(可能在任何地方!)内存问题,这会导致应用程序尝试访问实际上无效的内存地址。因此,导致崩溃。

由于 libdispatch 是崩溃线程的一部分,这可能暗示您的代码中使用 GCD 的某处可能是您的问题所在。如前所述,很可能是内存问题。

总的来说,我发现可靠地查找和解决内存问题的最佳方法是使用测试框架并自动执行应用交互,以便它运行很长时间。它还有助于通过一遍又一遍地重做相同的用户交互来实现自动化。它很可能会崩溃,但这次是可重现的,因此您可以在仪器旁边运行自动化。为此,我确实使用了 KIF 框架并取得了巨大的成功。

要获得完整的崩溃报告,您可能需要查看替代的崩溃报告解决方案,我在这里暗示了这一点:https://***.com/a/8242215/474794

【讨论】:

【参考方案2】:

您只能从 TestFlight 崩溃报告中的主线程获取堆栈跟踪。然而,真正的崩溃可能发生在另一个线程中,主线程处理了它。如果您可以使用相同的回溯重现该崩溃,那么 Mobclix 中确实存在错误。

您需要完整的崩溃报告,只有在您有权访问设备时才能获得该报告。

您可以在此答案中找到更多有用的信息: https://***.com/a/6462751/550177

编辑: 正如我所说,真正的崩溃是在不同的线程(线程 1)中。但我无法弄清楚是什么导致了崩溃。查看涉及 MyApp 的其他回溯(线程 4、6 和 12)。

【讨论】:

我将努力获取从设备发送的完整崩溃报告,我自己无法重现崩溃。 设法从设备获取完整的崩溃日志,任何帮助将不胜感激 我曾多次尝试使用相同的回溯重现崩溃,但没有产生一次崩溃。我不知道从这里去哪里

以上是关于iOS 5 上的应用程序崩溃的主要内容,如果未能解决你的问题,请参考以下文章

IOS 6 上的应用程序崩溃 - UIViewControllerHierarchyInconsistency

iOS 上的 Firebase 应用检查在构建时崩溃

UIPopoverController 在运行 iOS 5.0.1 的 iPad 上崩溃?

更改 CFDataRef 的字节时,iOS 6 上的 EXC_BAD_ACCESS 但不是 5

UITableViewCell indexPathForCell:iOS 7 上的应用程序崩溃

仅由于内存错误,iOS8 上的应用程序崩溃