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:
Richard Frith-MacDonald 2016-02-10 10:22:43 +00:00
parent da2f52bf56
commit 8a2bfb18b8
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>
* Source/NSUserDefaults.m:
Remove dependency on NSUserDefaults in order to parse property list
in program arguments ... get boolean defaults settings from the
argument domain
2016-02-09 Larry Campbell <lcampbel@akamai.com>
* Source/NSUserDefaults.m: Fix for bug #46956

View file

@ -610,21 +610,17 @@ inline NSThread*
GSCurrentThread(void)
{
NSThread *thr = pthread_getspecific(thread_object_key);
if (nil == thr)
{
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];
NS_DURING
{
thr = NSMapGet(_exitingThreads, (const void*)selfThread);
}
NS_HANDLER
{
[_exitingThreadsLock unlock];
DESTROY(selfThread);
[localException raise];
}
NS_ENDHANDLER
thr = NSMapGet(_exitingThreads, (const void*)selfThread);
[_exitingThreadsLock unlock];
DESTROY(selfThread);
}