我们在 libdispatch 内部函数中发生了奇怪的崩溃,经过数小时的研究,我们对发生的事情一无所知。
崩溃轨迹是:
Incident Identifier: 7A5CBCD8-28A3-4AC5-937A-D5BA69A64B67
CrashReporter Key: [TODO]
Hardware Model: iPhone5,2
Process: Memoir Dev [6973]
Path: /Users/USER/Memoir Dev.app/Memoir Dev
Identifier: com.veri.memoir-enterprise
Version: 0.9.191
Code Type: ARM
Parent Process: launchd [1]
Date/Time: 2013-03-03 20:55:42 +0000
OS Version: iPhone OS 6.1.2 (10B146)
Report Version: 104
Exception Type: SIGABRT
Exception Codes: #0 at 0x3ae66350
Crashed Thread: 1
Thread 0:
0 libsystem_kernel.dylib 0x3ae55e30 _mach_msg_trap + 20
1 CoreFoundation 0x000972bb __CFRunLoopServiceMachPort + 131
2 CoreFoundation 0x00095fdb __CFRunLoopRun + 819
3 CoreFoundation 0x32bc823d _CFRunLoopRunSpecific + 357
4 CoreFoundation 0x32bc80c9 _CFRunLoopRunInMode + 105
5 GraphicsServices 0x367a633b _GSEventRunModal + 75
6 UIKit 0x34ae42b9 _UIApplicationMain + 1121
7 Memoir Dev 0x0002a0d7 main (main.m:20)
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x3ae66350 ___pthread_kill + 8
1 libsystem_c.dylib 0x3ae1936b _abort + 95
2 libsystem_c.dylib 0x3adb212d _free + 361
3 libdispatch.dylib 0x000088d1 _dispatch_kevent_register + 169
4 libdispatch.dylib 0x00007e91 _dispatch_source_kevent_register + 33
5 libdispatch.dylib 0x00008957 _dispatch_timer_list_update + 27
6 libdispatch.dylib 0x00006b81 _dispatch_mgr_invoke + 389
7 libdispatch.dylib 0x00002378 _dispatch_mgr_thread + 36
Thread 2:
0 libsystem_kernel.dylib 0x3ae55e30 _mach_msg_trap + 20
[...]
关于我们的代码和场景的一些背景知识:
- 我们广泛使用 NSOperations 和 GCD 将数据上传到我们的服务器
- 崩溃似乎发生在应用程序在后台上传时,在 10 分钟限制内
- 在我们从 6.0.2 升级到 6.1 的几天后,使用 iOS 6.1 (10B143) 的 2 月 9 日左右开始发生崩溃
- 到目前为止,我们可以在 iOS 6.1.2 (10B146) 中重现它,但不能在 6.0.1 (10A523) 中重现
- 关于 SIGABRT 异常类型,似乎有人在调用“中止”函数(实际上,它是由“dispatch_kevent_register”调用的“免费”)
你们知道在 iOS 6.1 及更高版本中 GCD 中是否存在任何已知问题吗?
最佳答案
由于进程中的堆损坏,这是 free() 中止。
调度管理器线程是命中 abort() 的线程可能是偶然的(回溯表明它醒来以异步安装新的调度计时器源并且 malloc 在那个时候检测到损坏)。
您可能想尝试使用 GuardMalloc 运行(请参阅 XCode 方案编辑器中的诊断选项卡),它更有可能在实际发生损坏时给您一个崩溃点。
或者,各种 malloc 调试环境变量可能有助于追踪罪魁祸首,c.f. malloc(3) 中的环境
关于ios - 带有 iOS 6.1 的 GCD 中的 SIGABRT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15208326/