From 271a54ece981c8b661eb0b5e1f16e77298e9c617 Mon Sep 17 00:00:00 2001 From: theraven Date: Sat, 5 Sep 2009 17:28:01 +0000 Subject: [PATCH] Moved registration of runtime multithreaded handler to after the creation of the main thread's NSThread object. This fixes a potential issue where the runtime is already in multithreaded mode, calls the handler, and NSException crashes dereferencing the thread object. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28609 72102866-910b-0410-8b05-ffd578937521 --- Source/NSThread.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/NSThread.m b/Source/NSThread.m index 64308c5ab..f341e85a9 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -485,13 +485,6 @@ static NSThread *defaultThread; { if (self == [NSThread class]) { - /* - * The objc runtime calls this callback AFTER creating a new thread - - * which is not correct for us, but does at least mean that we can tell - * if we have become multi-threaded due to a call to the runtime directly - * rather than via the NSThread class. - */ - objc_set_thread_callback(gnustep_base_thread_callback); if (pthread_key_create(&thread_object_key, releaseThread)) { @@ -505,6 +498,14 @@ static NSThread *defaultThread; threadClass = self; [NSThread _createThreadForCurrentPthread]; defaultThread = [NSThread currentThread]; + + /* + * The objc runtime calls this callback AFTER creating a new thread - + * which is not correct for us, but does at least mean that we can tell + * if we have become multi-threaded due to a call to the runtime directly + * rather than via the NSThread class. + */ + objc_set_thread_callback(gnustep_base_thread_callback); } }