App Crashes with EXEC_BAD_ACCESS in GCDAsyncSocket.m

Hi, We have a VPN app using Packet Tunnel Provier running in bg. The app use this library to maintain some network connections.

Unexpectedly, the app crash in some cases we do not understand. We have this Crash Report from the device, and we also know (by attach debugger to the proccess) that it crashes on this line of code:

while (!isCancelled && [currentRunLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]])

Any idea what is the problem?

Check out the backtrace of the crashing thread:

Thread 2 name:  GCDAsyncSocket-CFStream
Thread 2 Crashed:
0 libobjc.A.dylib  … objc_release + 16
1 Foundation       … -[_NSThreadPerformInfo dealloc] + 52
2 Foundation       … __NSThreadPerformPerform + 192
3 CoreFoundation   … __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
4 CoreFoundation   … __CFRunLoopDoSource0 + 204
5 CoreFoundation   … __CFRunLoopDoSources0 + 256
6 CoreFoundation   … __CFRunLoopRun + 768
7 CoreFoundation   … CFRunLoopRunSpecific + 572
8 Foundation       … -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 232
9 CocoaAsyncSocket … 0x105098000 + 75216
…

Frame 9 is not symbolicated, but it’s clearly your third-party library running the run loop.

Frames 8 through 3 are standard run loop infrastructure.

Frames 2 and 1 indicating that the thread is cleaning up after some sort of -performSelector:onThread:… call.

Frame 0 indicates that this crashed trying to release a reference to an object, probably because the object is no longer valid.

The most likely cause of such crashes is a memory management problem, and I recommend that you engage the standard memory debugging tools to see if you can make it more reproducible.

ps In the medium term I recommend that you look at adopting Network framework rather than relying on this third-party library. It has many advantages, not least of which is that it doesn’t rely on run loops (-:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

App Crashes with EXEC_BAD_ACCESS in GCDAsyncSocket.m
 
 
Q