iOS崩溃报告:EXC_CRASH(SIGABRT) - stringByAppendingString

时间:2017-10-06 11:10:02

标签: ios objective-c iphone crash-reports

我正在尝试修复一个我无法重新创建的错误,它不会发生在我的设备(iPhone 5s)或任何iOS模拟器中,但只发生在我的客户端的iPhone 7中。当客户端删除并再次下载应用程序时,错误消失了,所以我现在正在寻找一个幽灵。

我能够从客户端电话获取崩溃日志文件并对其进行符号化。以下是我提取的一些有用信息:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

在未标记的崩溃报告中:(检查2和3行)

Last Exception Backtrace:
0   CoreFoundation                  0x18c92efe0 __exceptionPreprocess + 124
1   libobjc.A.dylib                 0x18b390538 objc_exception_throw + 56
2   CoreFoundation                  0x18c92ef28 +[NSException raise:format:] + 116
3   Foundation                      0x18d324df0 -[NSString stringByAppendingString:] + 112
4   myApp                           0x100119ea8 0x100004000 + 1138344
5   myApp                           0x100119784 0x100004000 + 1136516
6   UIKit                           0x192ad1204 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 380
7   UIKit                           0x192cdd738 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3452
8   UIKit                           0x192ce31e0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1684
9   UIKit                           0x192cf7d18 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3151 + 48
10  UIKit                           0x192ce0474 -[UIApplication workspaceDidEndTransaction:] + 168
11  FrontBoardServices              0x18e4d7884 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36
12  FrontBoardServices              0x18e4d76f0 -[FBSSerialQueue _performNext] + 176
13  FrontBoardServices              0x18e4d7aa0 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
14  CoreFoundation                  0x18c8dd42c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
15  CoreFoundation                  0x18c8dcd9c __CFRunLoopDoSources0 + 540
16  CoreFoundation                  0x18c8da9a8 __CFRunLoopRun + 744
17  CoreFoundation                  0x18c80ada4 CFRunLoopRunSpecific + 424
18  UIKit                           0x192aca384 -[UIApplication _run] + 652
19  UIKit                           0x192ac5058 UIApplicationMain + 208
20  myApp                           0x10014b8ac 0x100004000 + 1341612
21  libdyld.dylib                   0x18b81959c start + 4

并在符号化的崩溃报告中:(检查4和5行)

Last Exception Backtrace:
0   CoreFoundation                  0x185f7fd38 0x185e3e000 + 1318200
1   libobjc.A.dylib                 0x185494528 0x18548c000 + 34088
2   CoreFoundation                  0x185f7fc80 0x185e3e000 + 1318016
3   Foundation                      0x18686e760 0x186862000 + 51040
4   myApp                           0x10469f928 -[AppDelegate initViewController] (AppDelegate.m:96)
5   myApp                           0x10469f520 -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:30)
6   UIKit                           0x18f3ff050 0x18f380000 + 520272
7   UIKit                           0x18f5f2898 0x18f380000 + 2566296
8   UIKit                           0x18f5f76e4 0x18f380000 + 2586340
9   UIKit                           0x18f885454 0x18f380000 + 5264468
10  UIKit                           0x18fb551f0 0x18f380000 + 8212976
11  UIKit                           0x18f8850b8 0x18f380000 + 5263544
12  UIKit                           0x18f885928 0x18f380000 + 5265704
13  UIKit                           0x18ffee6e8 0x18f380000 + 13035240
14  UIKit                           0x18ffee58c 0x18f380000 + 13034892
15  UIKit                           0x18fd6a9c0 0x18f380000 + 10398144
16  UIKit                           0x18fefffc8 0x18f380000 + 12058568
17  UIKit                           0x18fd6a870 0x18f380000 + 10397808
18  UIKit                           0x18fb54850 0x18f380000 + 8210512
19  UIKit                           0x18f5f5e28 0x18f380000 + 2580008
20  UIKit                           0x18f9f96ec 0x18f380000 + 6788844
21  FrontBoardServices              0x188621768 0x188615000 + 51048
22  FrontBoardServices              0x18862a070 0x188615000 + 86128
23  libdispatch.dylib               0x185905048 0x185904000 + 4168
24  libdispatch.dylib               0x18590c6c8 0x185904000 + 34504
25  FrontBoardServices              0x188655a04 0x188615000 + 264708
26  FrontBoardServices              0x1886556a8 0x188615000 + 263848
27  FrontBoardServices              0x188655c44 0x188615000 + 265284
28  CoreFoundation                  0x185f28358 0x185e3e000 + 959320
29  CoreFoundation                  0x185f282d8 0x185e3e000 + 959192
30  CoreFoundation                  0x185f27b60 0x185e3e000 + 957280
31  CoreFoundation                  0x185f25738 0x185e3e000 + 948024
32  CoreFoundation                  0x185e462d8 0x185e3e000 + 33496
33  GraphicsServices                0x187cd7f84 0x187ccd000 + 44932
34  UIKit                           0x18f3f3880 0x18f380000 + 473216
35  myApp                           0x1046bc124 main (main.m:14)
36  libdyld.dylib                   0x18596a56c 0x185969000 + 5484

因此,在未标记的崩溃报告的第三行,它说:

0x18d324df0 -[NSString stringByAppendingString:] + 112

并在符号化崩溃报告的第4行:

0x10469f928 -[AppDelegate initViewController] (AppDelegate.m:96)

在96行的AppDelegate中,我有这段代码:

NSString *backColorString = [@"#" stringByAppendingString:[myModel sharedInstance].theme.BackColor];

所以唯一可能出错的是,如果问题确实在这里(?)就是

[HotelStay sharedInstance].theme.BackColor

必须返回nil或“”。

问题是我尝试了两种方法,但我无法重新创建问题。在这里我有什么遗漏或做错了吗?

1 个答案:

答案 0 :(得分:1)

如果你在stringByAppendingString上使用NSString而不是最终导致泄漏,因为与初始NSString关联的指针会四处移动,指向由追加创建的新字符串,而使用NSMutableString,您的指针始终指向该可变字符串。我想它应该是问题,但我想的是根据Apple Documentation附加到接收器的字符串。如果nil值为NSInvalidArgumentException,则该值不得为nil。