2012-07-17 106 views
1

我搜索了几个小时并阅读了很多message sent to deallocated instance帖子,并尝试了在这些帖子中提出的方法,但我仍然无法找到导致崩溃的错误。- [CFRunLoopTimer发布]:发送到释放实例的消息0x62398f80

我试图使NSZombieEnabledMallocStackLoggingMallocStackLoggingNoCompact并得到了这条线:

*** -[CFRunLoopTimer release]: message sent to deallocated instance 0x62398f80 

但在我的代码,我没有使用CFRunLoopTimerNSTimer

info malloc,我得到了以下的输出:

[Switching to process 97238 thread 0x11903] 
sharedlibrary apply-load-rules all 
mygame(97238,0xb01cd000) malloc: recording malloc stacks to disk using standard recorder 
(gdb) info malloc 0x62398f80 
Alloc: Block address: 0x62398f80 length: 128 
Stack - pthread: 0xac0422c0 number of frames: 41 
    0: 0xe9d22 in GMmalloc_zone_malloc_internal 
    1: 0xe9ebb in GMmalloc_zone_malloc 
    2: 0x142ba88 in __CFAllocatorSystemAllocate 
    3: 0x142ba63 in CFAllocatorAllocate 
    4: 0x142b8de in _CFRuntimeCreateInstance 
    5: 0x147c1c5 in CFRunLoopTimerCreate 
    6: 0x32bb831 in _ZN7WebCore22setSharedTimerFireTimeEd 
    7: 0x338dd4b in _ZN7WebCore21MainThreadSharedTimer11setFireTimeEd 
    8: 0x338daf3 in _ZN7WebCore12ThreadTimers17updateSharedTimerEv 
    9: 0x3397781 in _ZN7WebCore9TimerBase15setNextFireTimeEd 
    10: 0x339786a in _ZN7WebCore9TimerBase5startEdd 
    11: 0x2be78be in _ZN7WebCore5Frame9keepAliveEv 
    12: 0x2e86312 in _ZN7WebCore15JSDOMWindowBase10globalExecEv 
    13: 0x2ea699a in _ZN7WebCore15JSEventListener11handleEventEPNS_22ScriptExecutionContextEPNS_5EventE 
    14: 0x2bc4e02 in _ZN7WebCore11EventTarget18fireEventListenersEPNS_5EventEPNS_15EventTargetDataERN3WTF6VectorINS_23RegisteredEventListenerELm1EEE 
    15: 0x2bc4f1c in _ZN7WebCore11EventTarget18fireEventListenersEPNS_5EventE 
    16: 0x2bc46ee in _ZN7WebCore11EventTarget13dispatchEventEN3WTF10PassRefPtrINS_5EventEEE 
    17: 0x33eb040 in _ZN7WebCore9WebSocket10didConnectEv 
    18: 0x33eafa4 in _ZThn20_N7WebCore9WebSocket10didConnectEv 
    19: 0x33ed470 in _ZN7WebCore16WebSocketChannel13processBufferEv 
    20: 0x33edd18 in _ZN7WebCore16WebSocketChannel14didReceiveDataEPNS_18SocketStreamHandleEPKci 
    21: 0x32c681b in _ZN7WebCore18SocketStreamHandle18readStreamCallbackEm 
    22: 0x32c68f8 in _ZN7WebCore18SocketStreamHandle18readStreamCallbackEP14__CFReadStreammPv 
    23: 0x14c803d in _signalEventSync 
    24: 0x14c879a in _cfstream_solo_signalEventSync 
    25: 0x14c7e41 in _CFStreamSignalEvent 
    26: 0x14c86f7 in CFReadStreamSignalEvent 
    27: 0x1ca371 in _ZN12SocketStream40dispatchSignalFromSocketCallbackUnlockedEP24SocketStreamSignalHolder 
    28: 0x126011 in _ZN12SocketStream14socketCallbackEP10__CFSocketmPK8__CFDataPKv 
    29: 0x125f21 in _ZN12SocketStream22_SocketCallBack_streamEP10__CFSocketmPK8__CFDataPKvPv 
    30: 0x1495e14 in __CFSocketPerformV0 
    31: 0x14fb94f in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 
    32: 0x145eb43 in __CFRunLoopDoSources0 
    33: 0x145e424 in __CFRunLoopRun 
    34: 0x145dd84 in CFRunLoopRunSpecific 
    35: 0x145dc9b in CFRunLoopRunInMode 
    36: 0x1d5c7d8 in GSEventRunModal 
    37: 0x1d5c88a in GSEventRun 
    38: 0x39c626 in UIApplicationMain 
    39: 0x3095 in main at /Users/neevek/workspace/xcode_projects/mygame/mygame/main.m:16 
    40: 0x2925 in start 

编辑

我几乎绝望了,我花了2天这个问题。我唯一能发现的就是僵尸对象CFRunLoopTimer。我在我的代码中使用了CocoaHttpServerNSURLConnection。从某个地方我知道NSURLConnection取决于NSRunLoop,所以我不知道是否导致崩溃的NSRunLoop。在我的应用程序中,CocoaHTTPServerNSURLConnection都取决于NSRunLoop,因为它们运行在不同的线程上。

请帮忙!

我用仪器找到僵尸对象,并花了2个截图崩溃报告: enter image description here enter image description here

而且[HttpServer bonjourThread]方法:根据

enter image description here

+0

是否使用断点来查看它究竟在哪里崩溃? – Pierre 2012-07-17 07:23:15

+0

尝试恢复到上一个​​稳定版本,然后逐行添加新代码以查看哪一个崩溃 – iSofTom 2012-07-17 07:25:36

+0

它在每次运行中都没有崩溃,所以我不知道该设置断点的位置,我的应用程序会在启动时使用NSURLConnection发出大量的HTTP请求,我只是不知道如何调试它。 – neevek 2012-07-17 07:26:55

回答

0

唯一的解决办法对我来说是搜索你的代码NSTimer-任何第三部分库可以使用它。一旦发现NSTimer只是在NST末尾添加一个保留语句定时器初始化, 像这样:

idleTimer = [[NSTimer scheduledTimerWithTimeInterval:maxIdleTime 
                target:self 
                selector:@selector(idleTimerExceeded) 
                userInfo:nil 
                repeats:NO]retain]; 
1

我已经解决了这个问题,只是上下文调用方法之前呼吁的UIWebView虚拟stringByEvaluatingJavaScriptFromString。我相信这个工程的原因是调用javascript是在Web Thread上完成的,它使用计时器来接收回到主线程的回复,当调用这个计时器时没有创建,所以当回复从Web返回时线程崩溃试图释放一个永远不会创建的计时器。通过使用适当的API stringByEvaluatingJavaScriptFromString确保定时器被创建,然后invokeMethod可以使用相同的定时器。

JSContext* context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"]; 
JSValue* value = context[@"Colors"]; 

// timer CFRelease crash fix 
[webView stringByEvaluatingJavaScriptFromString:nil]; 

[value invokeMethod:@"update" withArguments:@[objectID,modifier]]; 
+0

我也遇到'[context evaluateScript:JSStr];''的崩溃。你有没有找到解决这个崩溃的办法? – Suryakant 2015-06-19 07:02:13

+0

是的,我找到了解决方案!请检查我上面更新的答案。 – malhal 2015-07-28 10:17:30

相关问题