这是由Reachability引起的libdispatch崩溃吗?

时间:2013-10-19 15:49:59

标签: ios7 grand-central-dispatch reachability libdispatch

有人能告诉我这个崩溃的堆栈是否似乎是由Reachability造成的?我正在运行Apple最新的Reachability实现,可以在https://developer.apple.com/library/ios/samplecode/reachability/Introduction/Intro.html

下载

我有一个应用程序,默认情况下ARC 启用(它是一个遗留应用程序),但我是基于每个文件启用它。我为Reachability.m启用了-fobjc-arc

当我查看这些线程时,我的代码无处可寻。我看到一些活动正在发生,因为WebHTMLView(可能是当前屏幕上的广告网络视图代码;它不是我的)。

在线程10上,我看到一个SCNetworkReachabilityDeallocate,然后是一个dispatch_semaphore_wait_slow,崩溃发生在libdispatch中的线程14上。

你认为这次崩溃是由Reachability代码引起的吗?我在使用-fobjc-arc和Reachability.m时犯了错误吗?

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x2000000c
Triggered by Thread:  14

Thread 0:
0   libsystem_kernel.dylib          0x39cafa84 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x39caf87c mach_msg + 36
2   CoreFoundation                  0x2f3e255c __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x2f3e0cc2 __CFRunLoopRun + 858
4   CoreFoundation                  0x2f34b53c CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x2f34b31e CFRunLoopRunInMode + 102
6   GraphicsServices                0x340822e6 GSEventRunModal + 134
7   UIKit                           0x31c021e0 UIApplicationMain + 1132
8   MyApp                           0x00053ad4 main (main.m:33)
9   libdyld.dylib                   0x39c0bab4 start + 0

Thread 1:
0   libsystem_kernel.dylib          0x39caf838 kevent64 + 24
1   libdispatch.dylib               0x39bfe0d0 _dispatch_mgr_invoke + 228
2   libdispatch.dylib               0x39bf863e _dispatch_mgr_thread + 34

Thread 2 name:  com.apple.NSURLConnectionLoader
Thread 2:
0   libsystem_kernel.dylib          0x39cb0910 close + 8
1   CoreFoundation                  0x2f370ef6 CFSocketInvalidate + 434
2   CFNetwork                       0x2f0122a2 Schedulables::_SchedulablesInvalidateApplierFunction(void const*, void*) + 14
3   CoreFoundation                  0x2f34af6e CFArrayApplyFunction + 34
4   CFNetwork                       0x2f011a94 SocketStream::close(void const*) + 280
5   CFNetwork                       0x2f01194e CoreStreamBase::_streamInterface_Close() + 46
6   CFNetwork                       0x2f030286 HTTPReadFilter::_streamImpl_Close() + 66
7   CFNetwork                       0x2f01194e CoreStreamBase::_streamInterface_Close() + 46
8   CFNetwork                       0x2f0301c6 NetConnection::shutdownConnectionStreams() + 98
9   CFNetwork                       0x2f0309c8 NetConnection::closeStreamsIfPossibleOrSignalThatThatNeedsToBeDonePrettyPlease() + 56
10  CFNetwork                       0x2f030d12 HTTPConnectionCacheEntry::removeUnauthConnection(NetConnection*) + 182
11  CoreFoundation                  0x2f34af6e CFArrayApplyFunction + 34
12  CFNetwork                       0x2f075678 HTTPConnectionCacheEntry::purgeIdleConnections(double, double) + 256
13  CFNetwork                       0x2f030ad4 HTTPConnectionCache::performIdleSweep() + 156
14  CFNetwork                       0x2f073b42 HTTPConnectionCache::timeoutIdleCellConnections() + 18
15  CFNetwork                       0x2f0b3394 ___ZNK17CoreSchedulingSet13_performAsyncEPKcU13block_pointerFvvE_block_invoke + 16
16  CoreFoundation                  0x2f34af6e CFArrayApplyFunction + 34
17  CFNetwork                       0x2f019f10 RunloopBlockContext::perform() + 160
18  CFNetwork                       0x2f019de2 MultiplexerSource::perform() + 218
19  CFNetwork                       0x2f019c70 MultiplexerSource::_perform(void*) + 44
20  CoreFoundation                  0x2f3e2f24 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
21  CoreFoundation                  0x2f3e23ea __CFRunLoopDoSources0 + 202
22  CoreFoundation                  0x2f3e0bda __CFRunLoopRun + 626
23  CoreFoundation                  0x2f34b53c CFRunLoopRunSpecific + 520
24  CoreFoundation                  0x2f34b31e CFRunLoopRunInMode + 102
25  Foundation                      0x2fd8664c +[NSURLConnection(Loader) _resourceLoadLoop:] + 316
26  Foundation                      0x2fdfbdc2 __NSThread__main__ + 1058
27  libsystem_pthread.dylib         0x39d28c5a _pthread_body + 138
28  libsystem_pthread.dylib         0x39d28bca _pthread_start + 98
29  libsystem_pthread.dylib         0x39d26ccc thread_start + 4

Thread 3 name:  WebThread
Thread 3:
0   CoreGraphics                    0x2f49163c CGRectIsEmpty + 0
1   WebCore                         0x37291700 -[WAKView setNeedsDisplayInRect:] + 76
2   WebKit                          0x37cad22a -[WebHTMLView setNeedsDisplayInRect:] + 214
3   WebCore                         0x372915cc WebCore::ScrollView::platformRepaintContentRectangle(WebCore::IntRect const&, bool) + 148
4   WebCore                         0x37291412 WebCore::ScrollView::repaintContentRectangle(WebCore::IntRect const&, bool) + 98
5   WebCore                         0x37291272 WebCore::FrameView::doDeferredRepaints() + 90
6   WebCore                         0x372dc96c WebCore::FrameView::layout(bool) + 1748
7   WebCore                         0x3721fb94 WebCore::ThreadTimers::sharedTimerFiredInternal() + 132
8   WebCore                         0x3721fae6 WebCore::timerFired(__CFRunLoopTimer*, void*) + 22
9   CoreFoundation                  0x2f3e2e84 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 12
10  CoreFoundation                  0x2f3e2a9e __CFRunLoopDoTimer + 790
11  CoreFoundation                  0x2f3e0e26 __CFRunLoopRun + 1214
12  CoreFoundation                  0x2f34b53c CFRunLoopRunSpecific + 520
13  CoreFoundation                  0x2f34b31e CFRunLoopRunInMode + 102
14  WebCore                         0x372ae7d8 RunWebThread(void*) + 416
15  libsystem_pthread.dylib         0x39d28c5a _pthread_body + 138
16  libsystem_pthread.dylib         0x39d28bca _pthread_start + 98
17  libsystem_pthread.dylib         0x39d26ccc thread_start + 4

Thread 4:
0   libsystem_kernel.dylib          0x39cafa84 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x39caf87c mach_msg + 36
2   CoreFoundation                  0x2f3e255c __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x2f3e0c7c __CFRunLoopRun + 788
4   CoreFoundation                  0x2f34b53c CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x2f34b31e CFRunLoopRunInMode + 102
6   libAVFAudio.dylib               0x2e3295ae GenericRunLoopThread::Entry(void*) + 126
7   libAVFAudio.dylib               0x2e31dbf4 CAPThread::Entry(CAPThread*) + 176
8   libsystem_pthread.dylib         0x39d28c5a _pthread_body + 138
9   libsystem_pthread.dylib         0x39d28bca _pthread_start + 98
10  libsystem_pthread.dylib         0x39d26ccc thread_start + 4

Thread 5 name:  JavaScriptCore::BlockFree
Thread 5:
0   libsystem_kernel.dylib          0x39cc1f38 __psynch_cvwait + 24
1   libsystem_pthread.dylib         0x39d28262 _pthread_cond_wait + 538
2   libsystem_pthread.dylib         0x39d2903c pthread_cond_wait + 36
3   JavaScriptCore                  0x3036f408 JSC::BlockAllocator::blockFreeingThreadMain() + 204
4   JavaScriptCore                  0x3036ca70 WTF::wtfThreadEntryPoint(void*) + 12
5   libsystem_pthread.dylib         0x39d28c5a _pthread_body + 138
6   libsystem_pthread.dylib         0x39d28bca _pthread_start + 98
7   libsystem_pthread.dylib         0x39d26ccc thread_start + 4

Thread 6 name:  JavaScriptCore::Marking
Thread 6:
0   libsystem_kernel.dylib          0x39cc1f38 __psynch_cvwait + 24
1   libsystem_pthread.dylib         0x39d28262 _pthread_cond_wait + 538
2   libsystem_pthread.dylib         0x39d2903c pthread_cond_wait + 36
3   JavaScriptCore                  0x3050daf2 JSC::GCThread::waitForNextPhase() + 74
4   JavaScriptCore                  0x3050db4c JSC::GCThread::gcThreadMain() + 48
5   JavaScriptCore                  0x3036ca70 WTF::wtfThreadEntryPoint(void*) + 12
6   libsystem_pthread.dylib         0x39d28c5a _pthread_body + 138
7   libsystem_pthread.dylib         0x39d28bca _pthread_start + 98
8   libsystem_pthread.dylib         0x39d26ccc thread_start + 4

Thread 7 name:  com.apple.CFSocket.private
Thread 7:
0   libsystem_kernel.dylib          0x39cc2440 select$DARWIN_EXTSN + 20
1   CoreFoundation                  0x2f3e645e __CFSocketManager + 482
2   libsystem_pthread.dylib         0x39d28c5a _pthread_body + 138
3   libsystem_pthread.dylib         0x39d28bca _pthread_start + 98
4   libsystem_pthread.dylib         0x39d26ccc thread_start + 4

Thread 8 name:  AFNetworking
Thread 8:
0   libsystem_kernel.dylib          0x39cafa84 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x39caf87c mach_msg + 36
2   CoreFoundation                  0x2f3e255c __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x2f3e0c7c __CFRunLoopRun + 788
4   CoreFoundation                  0x2f34b53c CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x2f34b31e CFRunLoopRunInMode + 102
6   Foundation                      0x2fd39822 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
7   Foundation                      0x2fd8a664 -[NSRunLoop(NSRunLoop) run] + 76
8   MyApp                           0x002c33d0 +[AFURLConnectionOperation networkRequestThreadEntryPoint:] (AFURLConnectionOperation.m:184)
9   Foundation                      0x2fdfbdc2 __NSThread__main__ + 1058
10  libsystem_pthread.dylib         0x39d28c5a _pthread_body + 138
11  libsystem_pthread.dylib         0x39d28bca _pthread_start + 98
12  libsystem_pthread.dylib         0x39d26ccc thread_start + 4

Thread 9 name:  WebCore: CFNetwork Loader
Thread 9:
0   libsystem_kernel.dylib          0x39cafa84 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x39caf87c mach_msg + 36
2   CoreFoundation                  0x2f3e255c __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x2f3e0c7c __CFRunLoopRun + 788
4   CoreFoundation                  0x2f34b53c CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x2f34b31e CFRunLoopRunInMode + 102
6   WebCore                         0x372f7872 WebCore::runLoaderThread(void*) + 250
7   JavaScriptCore                  0x3036ca70 WTF::wtfThreadEntryPoint(void*) + 12
8   libsystem_pthread.dylib         0x39d28c5a _pthread_body + 138
9   libsystem_pthread.dylib         0x39d28bca _pthread_start + 98
10  libsystem_pthread.dylib         0x39d26ccc thread_start + 4

Thread 10:
0   libsystem_kernel.dylib          0x39cafad4 semaphore_wait_trap + 8
1   libdispatch.dylib               0x39bfcdec _dispatch_semaphore_wait_slow + 172
2   libxpc.dylib                    0x39d370d6 xpc_connection_send_message_with_reply_sync + 150
3   SystemConfiguration             0x31b77362 _reach_server_target_remove + 90
4   SystemConfiguration             0x31b772d2 __SCNetworkReachabilityServer_targetRemove + 38
5   SystemConfiguration             0x31b5e318 __SCNetworkReachabilityDeallocate + 92
6   CoreFoundation                  0x2f347efc CFRelease + 464
7   libdispatch.dylib               0x39bfc7e0 _dispatch_root_queue_drain + 220
8   libdispatch.dylib               0x39bfc9cc _dispatch_worker_thread2 + 52
9   libsystem_pthread.dylib         0x39d26dfc _pthread_wqthread + 296
10  libsystem_pthread.dylib         0x39d26cc0 start_wqthread + 4

Thread 11:
0   libsystem_kernel.dylib          0x39cc2c7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x39d26e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x39d26cc0 start_wqthread + 4

Thread 12:
0   libsystem_kernel.dylib          0x39cc2c7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x39d26e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x39d26cc0 start_wqthread + 4

Thread 13:
0   libsystem_kernel.dylib          0x39cafa84 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x39caf87c mach_msg + 36
2   CoreFoundation                  0x2f3e255c __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x2f3e0c7c __CFRunLoopRun + 788
4   CoreFoundation                  0x2f34b53c CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x2f38f1a6 CFRunLoopRun + 94
6   CoreMotion                      0x2fa03394 ___lldb_unnamed_function1407$$CoreMotion + 724
7   libsystem_pthread.dylib         0x39d28c5a _pthread_body + 138
8   libsystem_pthread.dylib         0x39d28bca _pthread_start + 98
9   libsystem_pthread.dylib         0x39d26ccc thread_start + 4

Thread 14 Crashed:
0   libobjc.A.dylib                 0x3970db66 objc_msgSend + 6
1   CoreFoundation                  0x2f347f58 CFRelease + 556
2   libdispatch.dylib               0x39bf7100 _dispatch_call_block_and_release + 8
3   libdispatch.dylib               0x39bfbe72 _dispatch_queue_drain + 370
4   libdispatch.dylib               0x39bf8f96 _dispatch_queue_invoke + 38
5   libdispatch.dylib               0x39bfc74e _dispatch_root_queue_drain + 74
6   libdispatch.dylib               0x39bfc9cc _dispatch_worker_thread2 + 52
7   libsystem_pthread.dylib         0x39d26dfc _pthread_wqthread + 296
8   libsystem_pthread.dylib         0x39d26cc0 start_wqthread + 4

1 个答案:

答案 0 :(得分:0)

这次崩溃可能是由任何一段代码引起的,包括你自己的代码。

堆栈跟踪表明一个块以前保留了一个现在正在使用CFRelease释放的指针。如果指针未在第一时间正确保留 - 或者在最初保留时正在被解除分配,则可以看到此堆栈跟踪。

如果您正在访问一个线程上的指针,但是另一个线程将其释放,那么您可能会遇到可能导致此类崩溃的竞争条件。