[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSThread and problem posting notification

From: Lucas Schnorr
Subject: NSThread and problem posting notification
Date: Mon, 05 Mar 2012 10:52:32 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2


Everything below use the latest base, gui and the gnustep runtime, from the subversion repository at gna. All compiled with clang in an ubuntu system, 64 bits.

I have a program that launches a thread to do some background work. After the thread finishes, I get an exception:

2012-03-05 10:08:26.409 tobjc[6709] Problem posting notification: <NSException: 0x7f22d8005658> NAME:NSRangeException REASON:Index -1 is out of range 1 (in 'objectAtIndex:') INFO:{Array = ("<NSRunLoop: 0x1cfe998>"); Count = 1; Index = 4294967295; }

When this exception appears, I need to kill the program by hand.

Here's the backtrace:

#0  -[NSException raise] (self=0xabd048, _cmd=0x7ffff6ebc8b0)
    at /home/schnorr/misc/gnustep/core/base/Source/NSException.m:956
#1 0x00007ffff684418c in -[GSArray _raiseRangeExceptionWithIndex:from:] (self=0xb08398,
    _cmd=0x7ffff6ebc9f0, index=4294967295, sel=0x7ffff6ee93c0)
    at /home/schnorr/misc/gnustep/core/base/Source/GSArray.m:97
#2 0x00007ffff684500e in -[GSArray objectAtIndex:] (self=0xb08398, _cmd=0x7ffff6ee93c0, index=4294967295) at /home/schnorr/misc/gnustep/core/base/Source/GSArray.m:331 #3 0x00007ffff6900df9 in -[NSConnection removeRunLoop:] (self=0xb5ee18, _cmd=0x7ffff6ee8a90, loop=0xe469c8) at /home/schnorr/misc/gnustep/core/base/Source/NSConnection.m:1596 #4 0x00007ffff6914bd7 in +[NSConnection(Private) _threadWillExit:] (self=0x7ffff6ee8a00,
    _cmd=0x7ffff6ee91a0, notification=0xb5ef48)
    at /home/schnorr/misc/gnustep/core/base/Source/NSConnection.m:4020
#5 0x00007ffff69c29ef in -[NSNotificationCenter _postAndRelease:] (self=0x7472d8, _cmd=0x7ffff6f12f20, notification=0xb5ef48) at /home/schnorr/misc/gnustep/core/base/Source/NSNotificationCenter.m:1223 #6 0x00007ffff69c33b5 in -[NSNotificationCenter postNotificationName:object:userInfo:] (self=0x7472d8,
    _cmd=0x7ffff6f3fd90, name=0x79e578, object=0xacd628, info=0x0)
at /home/schnorr/misc/gnustep/core/base/Source/NSNotificationCenter.m:1282
#7  0x00007ffff6a80d91 in unregisterActiveThread (thread=0xacd628)
    at /home/schnorr/misc/gnustep/core/base/Source/NSThread.m:459
#8 0x00007ffff6a80bf6 in +[NSThread exit] (self=0x7ffff6f3fa80, _cmd=0x7ffff6f3fe00)
    at /home/schnorr/misc/gnustep/core/base/Source/NSThread.m:523
#9  0x00007ffff6a82445 in nsthreadLauncher (thread=0xacd628)
    at /home/schnorr/misc/gnustep/core/base/Source/NSThread.m:809
#10 0x00007ffff5f48efc in start_thread (arg=0x7fffeb72d700) at pthread_create.c:304 #11 0x00007ffff5c8389d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#12 0x0000000000000000 in ?? ()

I have made a small example so that you can try to reproduce the problem:

git clone git://github.com/schnorr/tobjc.git
cd tobjc

Click on "Start/Stop Thread" (or Alt+t), see that the thread was created in the terminal, then click again in the same button to stop the thread (with [thread cancel], the thread checks at each loop if it was canceled). When the thread stops, the exception above appears. The code for all this is on tobjc.m source file.

Am I doing something wrong when starting/canceling the thread, or it is a bug in NSThread, NSNotificationCenter or NSConnection?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]