From 496dc94164a3f195b03e3238138b4d3a1fbb0144 Mon Sep 17 00:00:00 2001 From: qmathe Date: Thu, 15 Nov 2012 16:34:54 +0000 Subject: [PATCH] Fixed -emptyPool ARC_RUNTIME implementation not to push a pool to the cache, -dealloc does it already. The previous implementation could result in a pool being reused while still in use. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35795 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 9 +++++++++ Source/NSAutoreleasePool.m | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 57bb8acc0..e81c7f59f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-11-15 Quentin Mathe + + * Source/NSAutoreleasePool.m (-emptyPool): Fixed not to push a pool to + the cache in the ARC_RUNTIME implementation, -dealloc does it already. + For the same current pool instance, the ARC_RUNTIME implementation was + calling push_pool_to_cache() twice, once in -emptyPool and another + -dealloc. Which meant a pool still in use could be reused, then it was + possible to get stuck in an infinite loop. + 2012-11-05 Wolfgang Lux * Source/GSFFIInvocation.m (GSFFIInvocationCallback): Generate diff --git a/Source/NSAutoreleasePool.m b/Source/NSAutoreleasePool.m index 5f86da68c..2230e4ab3 100644 --- a/Source/NSAutoreleasePool.m +++ b/Source/NSAutoreleasePool.m @@ -369,6 +369,12 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv) format: @"Too many (%u) autorelease pools ... leaking them?", level]; } } + + /* Catch the case where the receiver is a pool still in use (wrongly put in + the pool cache previously). */ + NSCAssert(_child != self, @"Invalid child pool"); + NSCAssert(_parent != self, @"Invalid parent pool"); + return self; } @@ -401,12 +407,6 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv) - (void) emptyPool { struct autorelease_thread_vars *tv = ARP_THREAD_VARS; - while (_child) - { - NSAutoreleasePool *pool = _child; - _child = pool->_child; - push_pool_to_cache(tv, pool); - } tv->current_pool = self; objc_autoreleasePoolPop(_released); }