Using static NSString as observation context

Christiaan Hofman cmhofman at gmail.com
Tue May 27 11:16:40 PDT 2008


I know, but I never send an (auto)release message to NSUserDefaults or  
NSUserDefaultsController, ever. Why would I, those are shared objects?  
That's my point of saying that the object is the shared  
NSUserDefaultsController, I thought that should be obvious. And it's  
pretty easy to check that I don't, because I can easily find every  
single occurrence where I send messages to those object in my code.

Unfortunately I cannot debug this problem, as I don't see the bug. I  
only see the bug reports from my users. So running with zombies is  
pointless.

Christiaan

On 27 May 2008, at 7:49 PM, Ken Ferry wrote:

> If you overrelease an object, including the user defaults controller,
> it could be deallocated.  Also, if an object is overreleased and gets
> deallocated, that memory location can end up reused for some other
> object.
>
> Did you try running with zombies, as Shawn suggested?  I would not
> suspect a cocoa bug here.
>
> -Ken
>
> On Tue, May 27, 2008 at 5:56 AM, Christiaan Hofman  
> <cmhofman at gmail.com> wrote:
>>
>> On 19 May 2008, at 7:56 PM, Paul Sargent wrote:
>>
>>>
>>> On 19 May 2008, at 17:48, Christiaan Hofman wrote:
>>>>
>>>> On 19 May 2008, at 5:39 PM, Shawn Erickson wrote:
>>>>>
>>>>> That type of crash implies to me that the object you  
>>>>> (indirectly) are
>>>>> sending removeObserver:forKeyPath: to is no longer a valid  
>>>>> object. Try
>>>>> debugging with NSZombie enabled.
>>>>>
>>>>> -Shawn
>>>>
>>>> That object is NSUserDefaultsController. That cannot be invalid  
>>>> (unless
>>>> there is a bug in AppKit).
>>>
>>> Not quite. Observers are implemented with some other hidden  
>>> objects and
>>> method redirection in the mix, so the remove message may not be  
>>> going direct
>>> to the NSUserDefaultsController.
>>
>> The only other objects I can think of to be in play are the  
>> observer, which
>> should definitely be valid at this point, and the shared  
>> NSUserDefaults
>> object, which is the one ultimately being observed.
>>
>> I am now pretty sure the static NSString must be a red haring.  
>> There should
>> be some other invalid object. As I'm pretty sure it's neither the  
>> observer
>> nor the controller, the only object I can think of is NSUserDefaults.
>>
>> One thing I've noticed: all crash reports are with 10.4 on a  
>> MacBook. So I
>> start to believe there is a Tiger AppKit bug involved. Has anyone  
>> else seen
>> problems with KVO on NSUserDefaultsController on Tiger?
>>
>> Christiaan
>>
>> _______________________________________________
>> MacOSX-dev mailing list
>> MacOSX-dev at omnigroup.com
>> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>>



More information about the MacOSX-dev mailing list