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

@ -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);
}