Thread deallocation fix ... retry deallocation of dictionary if it gets

re-used during thread deallocation.  If it still persists, leak memory
and log the problem.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9425 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2001-03-17 10:18:09 +00:00
parent cf6f142bc7
commit fe9eae5ffa
3 changed files with 22 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2001-03-17 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSThread.m: Revise scheme for deallocation of thread
dictionary ... keep it operating to avoid problems with stuff
trying to use it while deing deallocated. Log memory leaks.
2001-03-16 Nicola Pero <n.pero@mi.flashnet.it>
* Source/Makefile.postamble (after-install): Removed old

View file

@ -44,7 +44,6 @@ typedef enum
id _arg;
SEL _selector;
BOOL _active;
BOOL _deallocating;
@public
NSHandler *_exception_handler;
NSMutableDictionary *_thread_dictionary;

View file

@ -329,12 +329,26 @@ gnustep_base_thread_callback()
[NSException raise: NSInternalInconsistencyException
format: @"Deallocating an active thread without [+exit]!"];
}
_deallocating = YES;
DESTROY(_thread_dictionary);
DESTROY(_target);
DESTROY(_arg);
[NSAutoreleasePool _endThread: self];
if (_thread_dictionary != nil)
{
/*
* Try again to get rid of thread dictionary.
*/
init_autorelease_thread_vars(&_autorelease_vars);
DESTROY(_thread_dictionary);
[NSAutoreleasePool _endThread: self];
if (_thread_dictionary != nil)
{
init_autorelease_thread_vars(&_autorelease_vars);
NSLog(@"Oops - leak - thread dictionary is %@", _thread_dictionary);
[NSAutoreleasePool _endThread: self];
}
}
NSDeallocateObject(self);
}
@ -395,7 +409,7 @@ gnustep_base_thread_callback()
*/
- (NSMutableDictionary*) threadDictionary
{
if (_thread_dictionary == nil && _deallocating == NO)
if (_thread_dictionary == nil)
{
_thread_dictionary = [NSMutableDictionary new];
}