gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libobjc2 objc_setassociatedobject issue


From: David Chisnall
Subject: Re: libobjc2 objc_setassociatedobject issue
Date: Tue, 19 Nov 2013 08:51:16 +0000

This does indeed look like a runtime bug.  I'll take a look.

David

On 19 Nov 2013, at 01:33, Doug Warren <address@hidden> wrote:

> Hi Guys,
> 
> Was tracking a memory leak in an existing app and tracked it down to 
> objc_setassociatedobject not working as expected from the code being 
> developed for the Apple Runtime.  The docs around objc_setassociatedobject 
> seem to imply it follows the Apple Runtime but this simple gtest will pass on 
> Apple but fail on libobjc/GNUStep Base:
> 
> static BOOL deallocCalled = NO;
> static const char* objc_setAssociatedObjectKey = 
> "objc_setAssociatedObjectKey";
> 
> @interface NSMutableDictionary(setAssociatedObjectTest)
> @end
> 
> @implementation NSMutableDictionary(setAssociatedObjectTest)
> 
> -(void) dealloc
> {
>     deallocCalled = YES;
>     [super dealloc];
> }
> 
> @end
> 
> TEST(objc_setAssociatedObject, AssociatedObjectsAreReleased)
> {
>     @autoreleasepool {
>         NSObject* object = [[NSString alloc] init];
> 
>         NSMutableDictionary *info = [NSMutableDictionary 
> dictionaryWithCapacity:1];
>         objc_setAssociatedObject(object, &objc_setAssociatedObjectKey, info, 
> OBJC_ASSOCIATION_RETAIN);
> 
>         [object release];
>     }
> 
>     ASSERT_TRUE(deallocCalled);
> }
> 
> Adding calls to GSDebugAllocationList before/after the autorelease pool:
> 1     NSDataMalloc
> 1     GSMutableDictionary
> 
> Shows that the dictionary leaks.
> 
> Any thoughts?
> _______________________________________________
> Gnustep-dev mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/gnustep-dev




reply via email to

[Prev in Thread] Current Thread [Next in Thread]