2013-12-18 74 views
5

我在使用SocketRocket时遇到了iOS EXC_BAD_ACCESS错误,我不知道如何进一步调试问题以确定问题是出在我身边还是在SocketRocket的一侧。如何调试iOS上的iOS EXC_BAD_ACCESS KERN_INVALID_ADDRESS iOS

我得到的堆栈跟踪是:

Crashed: com.apple.main-thread 
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x2000000c 
raw 
0 libobjc.A.dylib  objc_msgSend + 5 
1 OMlearnings   SRWebSocket.m line 692 __30-[SRWebSocket _failWithError:]_block_invoke_2 
2 libdispatch.dylib _dispatch_call_block_and_release + 10 
10 UIKit    UIApplicationMain + 1136 
11 OMlearnings   main.m line 16 main 

或有时

Crashed: NSOperationQueue Serial Queue 
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xc 
raw 
0 libobjc.A.dylib  objc_msgSend + 5 
1 OMlearnings   SRWebSocket.m line 613 -[SRWebSocket scheduleInRunLoop:forMode:] 
2 OMlearnings   SRWebSocket.m line 600 -[SRWebSocket _connect] 
3 OMlearnings   OMSRealTimeTeamDashboard.m line 157 -[OMSRealTimeTeamDashboard sendMessage:] 
4 OMlearnings   OMSRealTimeTeamDashboard.m line 171 -[OMSRealTimeTeamDashboard eventReceived:] 
5 CoreFoundation  __invoking___ + 68 
6 CoreFoundation  -[NSInvocation invoke] + 282 
7 Foundation   -[NSInvocationOperation main] + 112 
8 Foundation   -[__NSOperationInternal _start:] + 770 
14 libsystem_pthread.dylib _pthread_wqthread + 298 

我的代码库是非常简单的,基本上订阅的事件,并在队列中执行socketrocket的sendMessage(处理并发)

[signalServices subscribe:my-event toBlock:^(NSNotification * notification) { 
    [this.queue addOperation:[[NSInvocationOperation alloc] initWithTarget:self selector:@selector(eventReceived:) object:notification]]; 
}]; 

- (void)eventReceived: (NSNotification *)notification { 
    // ... 
    [socket send:[NSString stringWithFormat:@"%i,1,%@", currentUserId.intValue, [NSNumber numberWithInt: rate.value]]]; 
} 

我读过使用NSZombies调试问题的人,但是m y问题很少发生,因此在问题出现之前我可能会耗尽内存。它工作正常99%的时间。

有没有什么需要了解iOS可以随机崩溃使用套接字等应用程序?例如,我们启用了后台获取,这可能是一些随机崩溃的原因吗?

谢谢!

+0

你解决了吗? – Spail

+0

那个更新? – franck

回答

4

在堆栈跟踪,发生在这条线

0 libobjc.A.dylib  objc_msgSend + 5 
1 OMlearnings   SRWebSocket.m line 692 __30-[SRWebSocket _failWithError:]_block_invoke_2 

EXC_BAD_ACCESS,https://github.com/square/SocketRocket/blob/master/SocketRocket/SRWebSocket.m#L692

[self.delegate webSocket:self didFailWithError:error]; 

根据该文件,https://github.com/square/SocketRocket

SRWebSocket 
(unlike NSURLConnection, SRWebSocket won't retain the delegate) 

@property (nonatomic, assign) id <SRWebSocketDelegate> delegate; 

委托属性不被保留SRWebSocket对象,因此,如果你不保留th e委托对象,它将与悬挂指针一起崩溃。你如何对委托对象有强烈的参考?

+1

我作为委托传递的对象是使用injective_register_singleton实例化的,所以它不太可能会引用 –

+1

为什么不在代码中粘贴代码? –