Fix recursion when looking up the current thread

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39351 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2016-02-10 10:22:43 +00:00
parent 7f8d7e6270
commit cdbaa85862
2 changed files with 15 additions and 11 deletions

View file

@ -1,9 +1,17 @@
2016-02-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSThread.m: In GSCurrentThread() the check for exiting
thread needs to NOT be wrapped in an exception handler, since the
exception handling code can attempt to get the current thread,
causing recursion.
2016-02-09 Richard Frith-Macdonald <rfm@gnu.org> 2016-02-09 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: * Source/NSUserDefaults.m:
Remove dependency on NSUserDefaults in order to parse property list Remove dependency on NSUserDefaults in order to parse property list
in program arguments ... get boolean defaults settings from the in program arguments ... get boolean defaults settings from the
argument domain argument domain
2016-02-09 Larry Campbell <lcampbel@akamai.com> 2016-02-09 Larry Campbell <lcampbel@akamai.com>
* Source/NSUserDefaults.m: Fix for bug #46956 * Source/NSUserDefaults.m: Fix for bug #46956

View file

@ -610,21 +610,17 @@ inline NSThread*
GSCurrentThread(void) GSCurrentThread(void)
{ {
NSThread *thr = pthread_getspecific(thread_object_key); NSThread *thr = pthread_getspecific(thread_object_key);
if (nil == thr) if (nil == thr)
{ {
NSValue *selfThread = NSValueCreateFromPthread(pthread_self()); NSValue *selfThread = NSValueCreateFromPthread(pthread_self());
/* NB this locked section cannot be protected by an exception handler
* because the exception handler stores information in the current
* thread variables ... which causes recursion.
*/
[_exitingThreadsLock lock]; [_exitingThreadsLock lock];
NS_DURING thr = NSMapGet(_exitingThreads, (const void*)selfThread);
{
thr = NSMapGet(_exitingThreads, (const void*)selfThread);
}
NS_HANDLER
{
[_exitingThreadsLock unlock];
DESTROY(selfThread);
[localException raise];
}
NS_ENDHANDLER
[_exitingThreadsLock unlock]; [_exitingThreadsLock unlock];
DESTROY(selfThread); DESTROY(selfThread);
} }