discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSValue valueWithNonretainedObject:


From: David Chisnall
Subject: Re: NSValue valueWithNonretainedObject:
Date: Tue, 9 Mar 2010 16:01:56 +0000

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.

> #2  0x00d106d6 in -[GSNonretainedObjectValue hash] (self=0x8727968, 
> _cmd=0xf357a0) at GSConcreteValueTemplate.m:187

This line is a #define in my copy, but I'd imagine that it is sending a -hash 
message to the non-retained object, which will crash if the object has been 
destroyed already.

> The NSValue is created in frame #8 and added to the mutable set in frame
> #7, as you might have guessed. The object wrapped in NSValue is an
> instance of a NSView subclass.
> 
> Can you extract meaningful informations from this backtrace ? I'm using
> base 1.19.3 but a quick test with svn trunk gave the same crash.

The most probably cause of this is that your NSView subclass has already been 
deallocated.  Put a breakpoint on its -dealloc method and make sure that this 
is not the case.  

David

-- Sent from my Apple II





reply via email to

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