Hi,
I know this is not directly related to CocoaHTTPServer, and maybe not even GCDAsyncSocket, but I'm
really hoping someone can point me in the right direction.
I'm integrating this server in a non-arc project, and followed the steps required to compile this project's files and dependency files as ARC.
(I might have missed something, but made sure of correct LLVM compiler and -fobjc-arc flags).
The debugger breaks with EXC_BAD_ACCESS on this line:
socket4FD = createSocket(AF_INET, interface4);
but I can actually set the last breakpoint inside that block before a crash on:
int socketFD = socket(domain, SOCK_STREAM, 0); // <-- crash
It always crashes in the same place, the stack doesn't offer any help, enabling zombies or allocations doesn't help:
GCDAsyncSocket: Creating IPv4 socket
(lldb) bt
* thread #1: tid = 0x1c03, MyApp, stop reason = EXC_BAD_ACCESS (code=2, address=0x947e28)
frame #0: MyApp
frame #1: 0x003be484 MyApp `__47-[GCDAsyncSocket acceptOnInterface:port:error:]_block_invoke_0229 + 1276 at GCDAsyncSocket.m:1585
frame #2: 0x33b9a796 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 22
frame #3: 0x33b9a60a libdispatch.dylib`dispatch_barrier_sync_f$VARIANT$up + 62
I'm starting the server like so:
-(id)init:(NSString *) docRootPath {
[DDLog addLogger:[DDTTYLogger sharedInstance]];
httpServer = [[HTTPServer alloc] init];
// [httpServer setType:@"_http._tcp."]; // don't want bonjour at this point
[httpServer setPort:49494]; // I also tried with dynamic port (comment out this line)
DDLogInfo(@"Setting document root: %@", docRootPath); // this prints a good string
[httpServer setDocumentRoot:docRootPath];
// Start the server (and check for problems)
NSError *error = nil;
if([httpServer start:&error])
{
DDLogInfo(@"Started HTTP Server on port %hu", [httpServer listeningPort]);
}
else
{
DDLogError(@"Error starting HTTP Server: %@", error);
}
return self;