我有以下堆栈跟踪:

Crashed: tcpConnWorkQueue (Not main thread)
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xf000000c
0 libobjc.A.dylib    objc_msgSend + 5
1 CoreFoundation     CFRelease + 560
2 libdispatch.dylib  _dispatch_call_block_and_release + 10
3 libdispatch.dylib  _dispatch_queue_drain + 374
4 libdispatch.dylib  _dispatch_queue_invoke + 42
5 libdispatch.dylib  _dispatch_root_queue_drain + 76
6 libdispatch.dylib  _dispatch_worker_thread2 + 56
7 libsystem_pthread.dylib    _pthread_wqthread + 298

所有其他堆栈看起来与我的代码无关。此堆栈跟踪是什么意思?在哪里可以找到代码中可能导致此类错误的错误?

主线程堆栈如下所示:
Thread : com.apple.main-thread
0  QuartzCore                     0x2fedef34 CA::Render::Object::unref() const + 35
1  QuartzCore                     0x2fedda73 CA::Context::commit_layer(CA::Layer*, unsigned int, unsigned int, void*) + 142
2  QuartzCore                     0x2fedda73 CA::Context::commit_layer(CA::Layer*, unsigned int, unsigned int, void*) + 142
3  QuartzCore                     0x2fedaa23 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 314
4  QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
5  QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
6  QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
7  QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
8  QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
9  QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
10 QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
11 QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
12 QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
13 QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
14 QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
15 QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
16 QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
17 QuartzCore                     0x2feda9c1 CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 216
18 QuartzCore                     0x2fed8d41 CA::Context::commit_transaction(CA::Transaction*) + 1048
19 QuartzCore                     0x2fed881f CA::Transaction::commit() + 314
20 QuartzCore                     0x2ff2d929 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 516
21 IOMobileFramebuffer            0x32b5d76d IOMobileFramebufferVsyncNotifyFunc + 104
22 IOKit                          0x2e7b4be5 IODispatchCalloutFromCFMessage + 248
23 CoreFoundation                 0x2da92b81 __CFMachPortPerform + 136
24 CoreFoundation                 0x2da9d777 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
25 CoreFoundation                 0x2da9d713 __CFRunLoopDoSource1 + 346
26 CoreFoundation                 0x2da9bedf __CFRunLoopRun + 1406
27 CoreFoundation                 0x2da06471 CFRunLoopRunSpecific + 524
28 CoreFoundation                 0x2da06253 CFRunLoopRunInMode + 106
29 GraphicsServices               0x327402eb GSEventRunModal + 138
30 UIKit                          0x302bb845 UIApplicationMain + 1136

最佳答案

级别1的堆栈跟踪显示已调用CFRelease,但是根据内核,您的地址0xf000000c无效,从而导致错误的访问异常。在最常见的情况下,当消息发送到已经释放的对象时,就会发生这种情况。

这种崩溃通常在第一次释放对象与第二次释放之间存在时间差。但是,由于具有0x2ff2d929 CA::Display::DisplayLink::dispatch_items,因此您具有在更新屏幕时触发的代码。
屏幕经常更新,因此应该经常调用。

您在程序中的任何地方都使用过+ (CADisplayLink *)displayLinkWithTarget:(id)target selector:(SEL)sel吗?您有- (void)invalidate电话吗?

用户界面可能正在从一个用例(例如玩具有基于显示计时器的屏幕更新的游戏)切换到另一种用例(例如在游戏结束时呈现菜单选项)。发生这种切换时,代码假设将失效,因此您必须取消回调,否则在设置不正确时会得到最终的回调(实际上是在游戏出现菜单时绘制了一个框架)。

当您在启用了“僵尸”的情况下运行程序时(“模式”部分中的复选框),则所有“已发布”对象都将成为“僵尸”-它会徘徊在等待对该对象进行调用。当有任何调用进入时,它会知道其编程错误并中止。然后,您可以查看该对象的分配历史记录,以了解该对象的首次分配和发布位置,以识别两次发布的错误。

关于ios - iPhone因tcpConnWorkQueue EXC_BAD_ACCESS而崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21295948/

10-13 04:36