gnustep-dev
[Top][All Lists]
Advanced

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

Re: NSBundle requires an NSAutoreleasePool


From: Tom Davie
Subject: Re: NSBundle requires an NSAutoreleasePool
Date: Tue, 16 Oct 2012 11:13:24 +0100

On 16 Oct 2012, at 11:07, Luboš Doležel <address@hidden> wrote:

> Hi,
> 
> see the attached very simple program. If you run it the way it is, it will 
> crash.
> 
> #0  0x00007ffff75fbef0 in -[NSException raise] () from 
> /usr/lib64/libgnustep-base.so.1.24
> #1  0x00007ffff752d8a4 in -[GSMutableDictionary setObject:forKey:] () from 
> /usr/lib64/libgnustep-base.so.1.24
> #2  0x00007ffff7586ca4 in -[NSBundle localizedStringForKey:value:table:] () 
> from /usr/lib64/libgnustep-base.so.1.24
> #3  0x00007ffff76cf2a0 in +[NSTimeZone systemTimeZone] () from 
> /usr/lib64/libgnustep-base.so.1.24
> #4  0x00007ffff76ce847 in +[NSTimeZone defaultTimeZone] () from 
> /usr/lib64/libgnustep-base.so.1.24
> #5  0x00007ffff76cc120 in -[NSLocalTimeZone secondsFromGMTForDate:] () from 
> /usr/lib64/libgnustep-base.so.1.24
> #6  0x00007ffff759390b in -[NSCalendarDate 
> descriptionWithCalendarFormat:locale:] () from 
> /usr/lib64/libgnustep-base.so.1.24
> #7  0x00007ffff7591c56 in -[NSCalendarDate descriptionWithCalendarFormat:] () 
> from /usr/lib64/libgnustep-base.so.1.24
> #8  0x00007ffff763bf30 in NSLogv () from /usr/lib64/libgnustep-base.so.1.24
> #9  0x00007ffff763bc34 in NSLog () from /usr/lib64/libgnustep-base.so.1.24
> #10 0x00007ffff757e106 in +[NSAutoreleasePool addObject:] () from 
> /usr/lib64/libgnustep-base.so.1.24
> #11 0x00007ffff765140c in -[NSObject autorelease] () from 
> /usr/lib64/libgnustep-base.so.1.24
> #12 0x00007ffff75efca5 in +[NSDictionary dictionary] () from 
> /usr/lib64/libgnustep-base.so.1.24
> #13 0x00007ffff75805a0 in +[NSBundle initialize] () from 
> /usr/lib64/libgnustep-base.so.1.24
> #14 0x00007ffff7bc2626 in objc_send_initialize (object=<optimized out>) at 
> dtable.c:733
> #15 0x00007ffff7bcbb26 in objc_msg_lookup_internal (receiver=<optimized out>, 
> selector=<optimized out>, receiver=<optimized out>, selector=<optimized out>, 
> sender=<optimized out>) at sendmsg2.c:73
> #16 objc_msg_lookup (receiver=<optimized out>, selector=<optimized out>) at 
> sendmsg2.c:398
> #17 0x000000000040087a in main () at bundletest.m:7
> 
> Uncomment the single commented line and it starts working.
> 
> +[NSDictionary dictionary] assumes that there is an autorelease pool.
> 
> 1) Is this assumption correct? Apple's documentation says nothing about using 
> autorelease.

According to apple's behaviour when there's no autorelease pool, the correct 
behaviour should be to leak in this scenario.  Apple also logs that it's leaking

> 2) If it is so, then callers of this method - such as [NSBundle initialize] - 
> should create their own pool instead of relying on the app to do that.

No, hence apple's log saying that it's leaking, it's up to the user to make 
sure that the autorelease pool is in place (though some things like run loops 
may be defined to create them for you).

Tom Davie


reply via email to

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