【问题标题】:Boundary Check Error边界检查错误
【发布时间】:2012-03-04 21:01:12
【问题描述】:

最近,我对 iOS 应用进行了一些更改。没什么特别的,但它最初是为 iOS 2.x 编写的应用程序,现在我不得不通过 Xcode 4.x 和 iOS 5 hoopla。我活了下来。至少,我是这么认为的。

作为整个操作的结果,我的应用程序现在可以在任何 iOS 设备上运行,除了带有 iOS 4.2.1 的第二代 iPod touch。 (原始版本在任何设备上都可以正常运行)。

令人费解的(至少对我而言)部分如下:

  • 应用程序在调试器中运行良好。同样退出应用程序后,我可以启动它,它会运行良好
  • 但是,如果我制作应用程序的(临时)存档,将其保存为 .ipa,然后通过 iTunes 同步将其发送到 iPod,应用程序会启动,但会在一段时间后崩溃。从 AppStore 下载的应用的行为与此完全相同。

我很想找出这里出了什么问题,但在调试期间不会出现问题。

我已经删除了遗留的 Entitlements.plist,但也玩弄了 Entitlements.plist。这并没有什么不同。 (正如您可能在字里行间看到的那样,我对这部分感到有点不安全,因为我并不真正理解 Entitlements.plist,也从未理解过它。)

另外,我确保在项目和目标级别上,iOS 部署目标都设置为 3.2,远低于 iPod 的操作系统版本。 Base SDK 设置为“最新 iOS”。

最后,我反复检查了 Xcode 是否是最新的。

超过 300.000 人下载了我的应用程序。根据 Flurry 的说法,6.6% 的人拥有这种硬件和软件的致命组合。在 AppStore 的最后一个版本信息中,我针对这个问题发出了警告,但我宁愿解决它。这是第一要务。理解问题是第二个。

请帮忙!

这是设备崩溃日志(我对此不太熟悉,所以我可能会发布太多):

Incident Identifier: 12DED19E-8BF2-4BE0-A578-4778498D6BE7
CrashReporter Key:   2040f536aa51a5eb273f2d57dd42f748032a4419
Hardware Model:      iPod2,1
Process:         MyApp [1858]
Path:            /var/mobile/Applications/C240F91A-3440-418A-8C6E-C7E6BD75761B/MyApp.app/MyApp
Identifier:      MyApp
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2012-03-04 22:53:37.585 +0100
OS Version:      iPhone OS 4.2.1 (8C148)
Report Version:  104

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

Thread 0 Crashed:
0   libSystem.B.dylib               0x32d25ad0 __kill + 8
1   libSystem.B.dylib               0x32d25abe kill + 4
2   libSystem.B.dylib               0x32d25ab2 raise + 10
3   libSystem.B.dylib               0x32d3cd5e abort + 54
4   libstdc++.6.dylib               0x3582fa00 __gnu_cxx::__verbose_terminate_handler() + 588
5   libobjc.A.dylib                 0x301888d8 _objc_terminate + 160
6   libstdc++.6.dylib               0x3582d100 __cxxabiv1::__terminate(void (*)()) + 76
7   libstdc++.6.dylib               0x3582d178 std::terminate() + 16
8   libstdc++.6.dylib               0x3582d2a0 __cxa_throw + 100
9   libobjc.A.dylib                 0x30186f28 objc_exception_throw + 104
10  CoreFoundation                  0x35e9670e -[__NSArrayI objectAtIndex:] + 150
11  MyApp                           0x00004932 -[RootViewController setInfo] (RootViewController.m:195)
12  MyApp                           0x0000437c -[RootViewController toggleView] (RootViewController.m:90)
13  CoreFoundation                  0x35eada3c -[NSObject(NSObject) performSelector:withObject:withObject:] + 20
14  UIKit                           0x3384af18 -[UIApplication sendAction:to:from:forEvent:] + 128
15  UIKit                           0x3384ae80 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
16  UIKit                           0x3384ae48 -[UIControl sendAction:to:forEvent:] + 44
17  UIKit                           0x3384aa98 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 528
18  UIKit                           0x3384b5c4 -[UIControl touchesEnded:withEvent:] + 452
19  UIKit                           0x3383cea8 -[UIWindow _sendTouchesForEvent:] + 580
20  UIKit                           0x3383c4dc -[UIWindow sendEvent:] + 388
21  UIKit                           0x3381fc94 -[UIApplication sendEvent:] + 444
22  UIKit                           0x3381f3ac _UIApplicationHandleEvent + 6816
23  GraphicsServices                0x35262c80 PurpleEventCallback + 1040
24  CoreFoundation                  0x35e9a5c4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 22
25  CoreFoundation                  0x35e9a582 __CFRunLoopDoSource1 + 158
26  CoreFoundation                  0x35e8c82e __CFRunLoopRun + 574
27  CoreFoundation                  0x35e8c504 CFRunLoopRunSpecific + 220
28  CoreFoundation                  0x35e8c412 CFRunLoopRunInMode + 54
29  GraphicsServices                0x35261d1c GSEventRunModal + 188
30  UIKit                           0x33865574 -[UIApplication _run] + 580
31  UIKit                           0x33862550 UIApplicationMain + 964
32  MyApp                           0x00002ba2 main (main.m:13)
33  MyApp                           0x00002b6c 0x1000 + 7020

这里是 SetInfo:

- (void) setInfo {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSInteger  theFrame = [defaults integerForKey:@"currentFrame"]; 
    MyAppAppDelegate * myDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
    NSMutableArray * currentCartoons = [myDelegate invert:[myDelegate readPreferences]];
    MyAppcartoon * thisCartoon = [currentCartoons objectAtIndex:theFrame];

    //format publication & date
    NSArray * titlePreSeparator = [thisCartoon.title componentsSeparatedByString:@"("];
    if ([titlePreSeparator count]>1) {
        NSString * titleSuffix = [titlePreSeparator objectAtIndex:1];
        NSArray * titleSeparator = [titleSuffix componentsSeparatedByString:@", "];
        NSString * pub = [titleSeparator objectAtIndex:0];
        flipsideViewController.Publication.text = pub;




    } else {// in case the publication metadata is missing from the rss
        flipsideViewController.Publication.text = @"";
    }

    //format title
    NSString * titlePrefix = [titlePreSeparator objectAtIndex:0];
    NSArray * titleFixer = [titlePrefix componentsSeparatedByString:@"F&S "];
    flipsideViewController.Title.text = [titleFixer objectAtIndex:1];

    //format date
    flipsideViewController.Date.text = [self formatDatefromrss:thisCartoon.publicationDate];

}

【问题讨论】:

  • 请将设备日志中的崩溃报告发布到 XCode 管理器中。
  • @NJones :我已将日志包含在原始问题中。希望能给个提示
  • 您可以发布您的 RootViewController 类的setInfo 方法吗?它是您的应用程序在访问数组时崩溃的方法,可能是索引超出范围。

标签: ios xcode debugging device


【解决方案1】:

我对这段代码有问题并不感到惊讶。检查它的界限非常小。虽然对我来说突出的objectAtIndex: 是:

flipsideViewController.Title.text = [titleFixer objectAtIndex:1];

如果这是您源代码中的第 195 行,我不会感到惊讶。

【讨论】:

  • 你是绝对正确的。我的错。我发现这是一个实际上在所有设备和所有操作系统上都存在的问题;我将为真正的问题打开一个新问题。我希望你会再次出现。
【解决方案2】:

好的,因此崩溃日志明确显示您的应用程序在您的 RootViewController 类的 setInfo 方法中崩溃(您可以在堆栈跟踪中看到,[__NSArrayI objectAtIndex:] 是从 setInfo 方法调用的)。您的 setInfo 方法有两个不安全的数组访问。 [titleFixer objectAtIndex:1];[titlePreSeparator objectAtIndex:0],几乎在方法的底部。

【讨论】:

  • 谢谢!我必须奖励 NJOnes,因为他是第一个。
猜你喜欢
  • 1970-01-01
  • 2011-08-01
  • 1970-01-01
  • 2016-07-11
  • 2011-08-31
  • 2011-05-27
  • 1970-01-01
  • 1970-01-01
  • 2019-05-10
相关资源
最近更新 更多