公司做IOS的走了,东西就丢给了我这个从来没有做过IOS的。最近为了捕获BUG,集成了MTA平台的BUG收集。问题就来了,对于我这种,虽然没有学过OC,但是写写代码还是可以的,xCode中调试下BUG也行,但是碰到这种Crash的,还不带崩溃路径的,完全不知道怎么复现,对于做了半个月IOS的我,的确略坑。
话说,国内的一些bug监控服务,不提供符号化就算了,但是,提供简单符号化,但是没有了堆栈地址,就太坑了。
Crash堆栈还原:
Incident Identifier: C087DE05-CDD8-4B47-B0AE-B0AE1D230CE2
CrashReporter Key: TODO
Hardware Model: iPhone8,2
Process: gpsbigben [423]
Path: /var/containers/Bundle/Application/12FD4C9D-7685-4247-9463-A8D222C47A25/gpsbigben.app/gpsbigben
Version: 2.7.4 (2.7.5)
Code Type: ARM-64
Parent Process: ??? [1]
Date/Time: 2016-06-23 02:45:09 +0000
OS Version: iPhone OS 9.3.1 (13E238)
Report Version: 104
Exception Type: SIGABRT
Exception Codes: #0 at 0x180e3411c
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Snapshot integerValue]: unrecognized selector sent to instance 0x15656d150'
Last Exception Backtrace:
0 CoreFoundation 0x000000018129ae38 + 124
1 libobjc.A.dylib 0x00000001808fff80 objc_exception_throw + 56
2 CoreFoundation 0x00000001812a1ccc + 0
3 CoreFoundation 0x000000018129ec74 + 872
4 CoreFoundation 0x000000018119cd1c _CF_forwarding_prep_0 + 92
5 gpsbigben 0x00000001001114b8 -[MapController mapView:markerInfoWindow:] + 536
6 CoreFoundation 0x00000001812a0ae0 + 144
7 CoreFoundation 0x0000000181198548 + 284
8 CoreFoundation 0x000000018119ce70 + 60
9 gpsbigben 0x000000010059ba84 -[GMSDelegateForward forwardInvocation:] + 120
10 CoreFoundation 0x000000018129eaa4 + 408
11 CoreFoundation 0x000000018119cd1c _CF_forwarding_prep_0 + 92
12 gpsbigben 0x0000000100575de0 -[GMSMapView infoWindowForMarker:] + 84
13 gpsbigben 0x00000001005730f8 -[GMSMapView setSelectedMarker:] + 84
14 gpsbigben 0x0000000100125698 -[OnlineViewController mapView:didTapMarker:] + 108
15 CoreFoundation 0x00000001812a0ae0 + 144
16 CoreFoundation 0x0000000181198548 + 284
17 CoreFoundation 0x000000018119ce70 + 60
18 gpsbigben 0x000000010059ba84 -[GMSDelegateForward forwardInvocation:] + 120
19 CoreFoundation 0x000000018129eaa4 + 408
20 CoreFoundation 0x000000018119cd1c _CF_forwarding_prep_0 + 92
21 gpsbigben 0x0000000100574448 -[GMSMapView didTapMarker:] + 72
22 gpsbigben 0x0000000100589da8 -[GMSMarker wasTapped] + 64
23 gpsbigben 0x0000000100497f8c -[GMSVectorMapView didTapAt:] + 1256
24 UIKit 0x0000000186975c8c + 164
25 UIKit 0x000000018658a5dc + 172
26 UIKit 0x0000000186417688 + 784
27 UIKit 0x000000018697728c + 72
28 UIKit 0x00000001863d63d8 + 372
29 UIKit 0x00000001863d3154 + 2404
30 CoreFoundation 0x00000001812507b0 + 32
31 CoreFoundation 0x000000018124e554 + 372
32 CoreFoundation 0x000000018124e984 + 928
33 CoreFoundation 0x0000000181178d10 CFRunLoopRunSpecific + 384
34 GraphicsServices 0x0000000182a60088 GSEventRunModal + 180
35 UIKit 0x000000018644df70 UIApplicationMain + 204
36 gpsbigben 0x00000001001097ec -[QBTitleView .cxx_destruct] + 152
37 libdyld.dylib 0x0000000180d168b8 + 4
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000180e3411c __pthread_kill + 8
1 libsystem_c.dylib 0x0000000180da5dac abort + 140
2 gpsbigben 0x00000001003a89a8 -[PLPLCrashReporter generateLiveReportWithThread:] + 0
3 CoreFoundation 0x000000018129b1c0 + 652
4 libobjc.A.dylib 0x000000018090023c + 112
5 libc++abi.dylib 0x00000001808f2f44 + 16
6 libc++abi.dylib 0x00000001808f2b10 __cxa_rethrow + 144
7 libobjc.A.dylib 0x0000000180900120 objc_exception_rethrow + 44
8 CoreFoundation 0x0000000181178db8 CFRunLoopRunSpecific + 552
9 GraphicsServices 0x0000000182a60088 GSEventRunModal + 180
10 UIKit 0x000000018644df70 UIApplicationMain + 204
11 gpsbigben 0x00000001001097ec -[QBTitleView .cxx_destruct] + 152
12 libdyld.dylib 0x0000000180d168b8 + 4
Thread 1:
0 libsystem_kernel.dylib 0x0000000180e354d8 kevent_qos + 8
1 libdispatch.dylib 0x0000000180ce7648 + 0
Thread 2:
0 libsystem_kernel.dylib 0x0000000180e18fd8 mach_msg_trap + 8
1 CoreFoundation 0x0000000181250ce8 + 196
2 CoreFoundation 0x000000018124e9ec + 1032
3 CoreFoundation 0x0000000181178d10 CFRunLoopRunSpecific + 384
4 CFNetwork 0x00000001818f9af4 + 412
5 Foundation 0x0000000181c6fe1c + 1000
6 libsystem_pthread.dylib 0x0000000180effb28 + 156
7 libsystem_pthread.dylib 0x0000000180effa8c + 0
8 libsystem_pthread.dylib 0x0000000180efd028 thread_start + 4
Thread 3:
0 libsystem_kernel.dylib 0x0000000180e18fd8 mach_msg_trap + 8
1 CoreFoundation 0x0000000181250ce8 + 196
2 CoreFoundation 0x000000018124e9ec + 1032
3 CoreFoundation 0x0000000181178d10 CFRunLoopRunSpecific + 384
4 CoreFoundation 0x00000001811c6464 CFRunLoopRun + 112
5 gpsbigben 0x00000001003845a4 -[APService clientThreadMain] + 100
6 Foundation 0x0000000181c6fe1c + 1000
7 libsystem_pthread.dylib 0x0000000180effb28 + 156
如上的简单符号化信息,做了半个月IOS,的确完全看不懂,百度了两篇关于Crash的文章学习了下,还是大部分看懂了。
http://blog.csdn.net/weiguang_123/article/details/50725865
http://blog.csdn.net/wangyanchang21/article/details/51162325
抓出来了一些重点如下:
Code Type: ARM-64
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[5]'
Last Exception Backtrace:
0 CoreFoundation 0x00000001818cadb0 + 124
1 libobjc.A.dylib 0x0000000180f2ff80 objc_exception_throw + 56
2 CoreFoundation 0x00000001817ae1a0 + 300
3 CoreFoundation 0x00000001817b9c48 + 52
4 gpsbigben 0x00000001000c8768 _mh_execute_header + 182120
不得不说,半符号化就是坑,不然可以通过上述的文章中说的atos直接得到错误位置了。atos的用法大致如下:
$ xcrun atos -o executable -arch architecture -l loadAddress
address ...
仔细看弄出来的重点,发现一个很奇怪的东西,_mh_execute_header,猜测这个是崩溃的地址,但是符号化失败,后面的+号,带着的是正确的偏移量,如果你仔细看过一些半符号化的Crash,+号后面带的就不是正确的偏移量了。那么
崩溃的地址_mh_execute_header=0x1000c8768 - 182120 = 0x1000F4ED0
地址就可以得到了,现在首先需要把dSYM文件弄到手,我用的是xcode直接发布的,手上当然没有安装包,由于对IDE不熟,也找不到在电脑的那个路径下面存放这个东西。为了和线上的包一致,只能再次打包,打包成功后选择那个包,右键–Show in Finder,看到了那个包,然后右键—显示包内容。然后找到DSYM文件。打开终端:
jeech:Documents jeech$ xcrun atos -o gpsbigben.app.dSYM/Contents/Resources/DWARF/gpsbigben -arch arm64 -l 0x10009c000 0x1000c8768
-[RegisterController submitClicked] (in gpsbigben) (RegisterController.m:481)
这样,就看到了崩溃的错位位置。行号是481,才知道如何复现,经过尝试,完全可以复现,并且错误额问题跟
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[5]'
的描述一致。问题解决。
这种方法,对于完全没有符号化或者符号化失败的Crash,是挺好的,但是国内的很多都是半符号化的,是提示了你的问题在那个方法内,但是没有行号。一洗比较奇怪的问题只能靠猜了。
PS:对于我这种没有基础的,完全算是半路出家做IOS,OC语法基本没学过,只是稍微了解IOS系统,但是碰到问题不慌,了解下系统的生命周期,代码模仿着写,只要思路没有什么问题,语言只不过是表现形式罢了,碰到新东西还是容易玩得开。