[Top][All Lists]

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

Re: NSValue valueWithNonretainedObject:

From: Philippe Roussel
Subject: Re: NSValue valueWithNonretainedObject:
Date: Tue, 09 Mar 2010 17:52:54 +0100

Hi David

Le mardi 09 mars 2010 à 16:01 +0000, David Chisnall a écrit :
> On 9 Mar 2010, at 15:03, Philippe Roussel wrote:
> > Hi all,
> > 
> > I'm trying to use [NSValue valueWithNonretainedObject:obj] to wrap an
> > object before adding it to a mutable set to avoid increasing its retain
> > count and I'm getting this backtrace :
> > 
> > #0  0x0011f7b2 in sarray_get_safe (receiver=0x867e598, op=0xf2fbc0) at 
> > /build/buildd/gcc-4.4-4.4.1/src/libobjc/objc/sarray.h:233
> > #1  objc_msg_lookup (receiver=0x867e598, op=0xf2fbc0) at 
> > /build/buildd/gcc-4.4-4.4.1/src/libobjc/sendmsg.c:225
> Crashes here usually mean that you are sending a message to an object that 
> has already been freed.  You can try using the NSZombie thing or running your 
> app in valgrind to find if this is the case.

Well, thanks !

I already tried with setting NSZombieEnabled in main() but it didn't
seem to work. Using the environment variable did the trick and revealed
my mistake : I didn't think the crash could come from an already freed
object as I'm adding it to the set in its init method. I totally missed
the fact that adding it to the set also meant sending -hash to the other
objects in the set...

Thanks again,

reply via email to

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