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
This commit is contained in:
David Chisnall 2009-09-05 17:28:01 +00:00
parent 0aa15f423c
commit 29faf077e7

View file

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