Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication Freezing when calling CocoaAsyncMethod scheduleDequeueRead
    primarykey
    data
    text
    <p>I'm using CocoaAsyncSocket library to create a TCP socket connection. The problem I'm having is after a few library methods are called, I'm getting an error.</p> <p>appDelegate:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { socket = [[AsyncSocket alloc] initWithDelegate:self]; NSError *error = nil; if (![socket connectToHost:@"199.5.83.63" onPort:11005 error:&amp;error]) { NSLog(@"Error connecting: %@", error); } [socket readDataWithTimeout:10 tag:1]; self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. self.viewController = [[[tekMatrixViewController alloc] initWithNibName:@"tekMatrixViewController" bundle:nil] autorelease]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; } </code></pre> <p>And here are my methods from the CocoaAsyncSocket Library:</p> <pre><code>- (void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { NSData *strData = [data subdataWithRange:NSMakeRange(0, [data length])]; NSString *msg = [[NSString alloc] initWithData:strData encoding:NSUTF8StringEncoding]; NSLog(@"RX length: %d", [data length]); if(msg) { NSLog(@"RX:%@",msg); } else { NSLog(@"Fail"); } } - (void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err { NSLog(@"error - disconnecting"); //start reconnecting procedure here... } - (void)onSocketDidDisconnect:(AsyncSocket *)sock { NSLog(@"disconnected"); } - (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port { NSLog(@"connected"); } </code></pre> <p>When I run my app in the simulator, this is what my output log spits out:</p> <pre><code>2012-06-08 13:17:30.808 tekMatrix[2793:f803] connected 2012-06-08 13:17:30.815 tekMatrix[2793:f803] RX length: 8 2012-06-08 13:17:30.816 tekMatrix[2793:f803] Fail </code></pre> <p>After that, I get an error in the AsyncSocket.m file (part of library) in this method:</p> <pre><code>- (void)scheduleDequeueRead { if((theFlags &amp; kDequeueReadScheduled) == 0) { theFlags |= kDequeueReadScheduled; [self performSelector:@selector(maybeDequeueRead) withObject:nil afterDelay:0 inModes:theRunLoopModes]; } } </code></pre> <p>Specifically, the error is on line:</p> <pre><code>[self performSelector:@selector(maybeDequeueRead) withObject:nil afterDelay:0 inModes:theRunLoopModes]; </code></pre> <p>And the exception is: <strong>Thread 1: BAD_EXC_ACCESS (code 1=0, address=0xd0688b8a)</strong></p> <p>After that, the app is completely frozen in the simulator. If anybody could offer some insight as to why this is causing the app to freeze, I would really appreciate it. </p> <p>Here is the library I'm using: <a href="https://github.com/robbiehanson/CocoaAsyncSocket" rel="nofollow noreferrer">CocoaAsyncSocket</a></p> <p><strong><em>EDIT:</em></strong></p> <p>After Enabling Zombie Objects and running the app in the simulator, this is spit out in the output:</p> <pre><code>2012-06-08 14:53:15.416 tekMatrix[3217:f803] *** -[__NSArrayI count]: message sent to deallocated instance 0x6d10a70 </code></pre> <p>I'll have to do a little digging on this and figure out what's happening.</p> <p><strong><em>EDIT 2:</em></strong></p> <p>After a little digging using instruments, I found out the following: </p> <pre><code>An Objective-C message was sent to a deallocated object (zombie) at address: 0x6b8bb10. </code></pre> <p><strong><em>EDIT 3:</em></strong></p> <p>Now the error reads: </p> <p>Thread 1: EXC_BREAKPOINT(code=EXC_I386_BPT, subcode=0x0)</p> <p>Here is a screenshot from instruments. I'm not really following how to interpret this, though. It looks like I'm sending a message to an object that has been deallocated. Is this true? If so, how do I go about figuring out where this occurs?</p> <p>If the image is hard to see, here's a direct link: <a href="http://i890.photobucket.com/albums/ac103/mmh924/ScreenShot2012-06-08at31523PM.png" rel="nofollow noreferrer">Instruments Screenshot</a></p> <p><img src="https://i.stack.imgur.com/fGx3p.png" alt="Instruments Screenshot"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload