Hi,
We finally got a Foundation library for linux working under 64bit. However we run into new problems in multithreading.
The app I'm trying to port is fully multi threaded. After spawning off a thread it creates an autorelease pool for that specific thread.
This however seems to cause a problem which raises an exception. And the string formatting to print the exception then raises an exception again. This loops at infinitum...
This is the code snipped of a generic new thread I use everywhere:
static void *new_thread(void *arg)
{
int ret;
struct new_thread_args *p = arg;
debug("gwlib.gwthread", 0, "Thread %ld (%s) maps to pid %ld.",
p->ti->number, p->ti->name, (long) p->ti->pid);
p->ti->pool = [[NSAutoreleasePool alloc] init]; <- causes the exception
(p->func)(p->arg);
Now I wonder if there could be a workaround or how Cocotron handles autorelease pools differently than MacOS X when it comes to threads.
Here's a end of a backtrace (after 145'500 stack frames)
#145548 0x00007ffff7a19693 in NSPlatformCurrentThread () at src/NSMemoryFunctions_posix.m:104
#145549 0x00007ffff7a6ae9b in NSThreadCurrentPool () at src/NSThread.m:305
#145550 0x00007ffff79de42f in NSAutorelease (object=<value optimized out>) at src/NSAutoreleasePool.m:102
#145551 0x00007ffff7a5df5f in NSStringWithFormatArguments (format=<value optimized out>, arguments=<value optimized out>) at src/NSStringFormatter.m:655
#145552 0x00007ffff79f7e0c in +[NSException raise:format:arguments:] (self=<value optimized out>, _cmd=0x0, name=<value optimized out>,
format=<value optimized out>, arguments=0x0) at src/NSException.m:42
#145553 0x00007ffff79f7de0 in +[NSException raise:format:] (self=<value optimized out>, _cmd=0x0, name=<value optimized out>, format=<value optimized out>)
at src/NSException.m:38
#145554 0x00007ffff7a19693 in NSPlatformCurrentThread () at src/NSMemoryFunctions_posix.m:104
#145555 0x00007ffff7a6ae9b in NSThreadCurrentPool () at src/NSThread.m:305
#145556 0x00007ffff79de42f in NSAutorelease (object=<value optimized out>) at src/NSAutoreleasePool.m:102
#145557 0x00007ffff7a5df5f in NSStringWithFormatArguments (format=<value optimized out>, arguments=<value optimized out>) at src/NSStringFormatter.m:655
#145558 0x00007ffff79f7e0c in +[NSException raise:format:arguments:] (self=<value optimized out>, _cmd=0x0, name=<value optimized out>,
format=<value optimized out>, arguments=0x0) at src/NSException.m:42
#145559 0x00007ffff79f7de0 in +[NSException raise:format:] (self=<value optimized out>, _cmd=0x0, name=<value optimized out>, format=<value optimized out>)
at src/NSException.m:38
#145560 0x00007ffff7a19693 in NSPlatformCurrentThread () at src/NSMemoryFunctions_posix.m:104
#145561 0x00007ffff7a6ae9b in NSThreadCurrentPool () at src/NSThread.m:305
#145562 0x00007ffff79de42f in NSAutorelease (object=<value optimized out>) at src/NSAutoreleasePool.m:102
#145563 0x00007ffff7a5df5f in NSStringWithFormatArguments (format=<value optimized out>, arguments=<value optimized out>) at src/NSStringFormatter.m:655
#145564 0x00007ffff79f7e0c in +[NSException raise:format:arguments:] (self=<value optimized out>, _cmd=0x0, name=<value optimized out>,
format=<value optimized out>, arguments=0x0) at src/NSException.m:42
#145565 0x00007ffff79f7de0 in +[NSException raise:format:] (self=<value optimized out>, _cmd=0x0, name=<value optimized out>, format=<value optimized out>)
at src/NSException.m:38
#145566 0x00007ffff7a19693 in NSPlatformCurrentThread () at src/NSMemoryFunctions_posix.m:104
#145567 0x00007ffff7a6ae9b in NSThreadCurrentPool () at src/NSThread.m:305
#145568 0x00007ffff79de1bf in -[NSAutoreleasePool init] (self=<value optimized out>, _cmd=0x0) at src/NSAutoreleasePool.m:49
#145569 0x000000000083f612 in new_thread (arg=0x72ac330) at gwlib/gwthread-pthread.m:401
#145570 0x0000003ed1a07851 in start_thread () from /lib64/libpthread.so.0
#145571 0x0000003ed12e76dd in clone () from /lib64/libc.so.6
(gdb)