Re: firstResponder KVO snow leopard crash; bug?

2009-11-18 Thread Aaron Clarke


On Nov 18, 2009, at 12:00 , Corbin Dunn wrote:



On Nov 17, 2009, at 1:04 PM, Aaron Clarke wrote:

We have an application that runs fine on leopard (10.5) but  
occasionally

crashes on snow leopard (10.6) when closing an NSWindow.  Here is the
backtrace for the crash:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x
0x976e691b in objc_msgSend ()
(gdb) bt
#0  0x976e691b in objc_msgSend ()
#1  0x197142d0 in ?? ()
#2  0x9031e88e in NSKeyValuePushPendingNotificationPerThread ()
#3  0x9031e224 in NSKeyValueWillChange ()
#4  0x9030350b in -[NSObject(NSKeyValueObserverNotification)
willChangeValueForKey:] ()
#5  0x90327cfe in _NSSetObjectValueAndNotify ()
#6  0x92745fb8 in -[NSWindow makeFirstResponder:] ()
...

Even if it doesn't crash, closing the NSWindow always results in the
following error message.

An instance 0x11b75230 of class MyWindow was deallocated while key  
value
observers were still registered with it. Observation info was  
leaked, and
may even become mistakenly attached to some other object. Set a  
breakpoint
on NSKVODeallocateBreak to stop here in the debugger. Here's the  
current

observation info:
 (
 Context: 0x0,
Property: 0x4453e60>
 Context: 0x0,
Property: 0x4453e60>
)

I looked at what the observer object's class is, and it's a  
subclass of

NSCollectionView.  We do not explicitly setup a KVO relationship for
firstResponder.  I also noticed that the "Application Kit Release  
Notes for
Snow Leopard" mention that firstResponder is KVO-compliant, which  
makes me
believe this is something new in Snow Leopard.  All this  
information makes
me believe this is potentially a bug in Application Kit for 10.6.   
Maybe we

setup an NSCollectionView incorrectly or I'm misinterpreting this
information?


Oh -- another thing. Does your subclass of NSCollectionView override:

(void)viewWillMoveToWindow:(NSWindow *)window {

but not call super? If not... call super! Your classes should always  
call super if it is defined in a superclass, unless you have a good  
reason to hide the super's behavior.


corbin






This was the problem, thank you.  This is a difficult bug to find in  
code someone else wrote.  This makes me almost wish there was a gcc  
flag for it (-Woverride-no-super).


-Aaron

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


firstResponder KVO snow leopard crash; bug?

2009-11-17 Thread Aaron Clarke
We have an application that runs fine on leopard (10.5) but occasionally
crashes on snow leopard (10.6) when closing an NSWindow.  Here is the
backtrace for the crash:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x
0x976e691b in objc_msgSend ()
(gdb) bt
#0  0x976e691b in objc_msgSend ()
#1  0x197142d0 in ?? ()
#2  0x9031e88e in NSKeyValuePushPendingNotificationPerThread ()
#3  0x9031e224 in NSKeyValueWillChange ()
#4  0x9030350b in -[NSObject(NSKeyValueObserverNotification)
willChangeValueForKey:] ()
#5  0x90327cfe in _NSSetObjectValueAndNotify ()
#6  0x92745fb8 in -[NSWindow makeFirstResponder:] ()
...

Even if it doesn't crash, closing the NSWindow always results in the
following error message.

An instance 0x11b75230 of class MyWindow was deallocated while key value
observers were still registered with it. Observation info was leaked, and
may even become mistakenly attached to some other object. Set a breakpoint
on NSKVODeallocateBreak to stop here in the debugger. Here's the current
observation info:
 (
 Context: 0x0,
Property: 0x4453e60>
 Context: 0x0,
Property: 0x4453e60>
)

I looked at what the observer object's class is, and it's a subclass of
NSCollectionView.  We do not explicitly setup a KVO relationship for
firstResponder.  I also noticed that the "Application Kit Release Notes for
Snow Leopard" mention that firstResponder is KVO-compliant, which makes me
believe this is something new in Snow Leopard.  All this information makes
me believe this is potentially a bug in Application Kit for 10.6.  Maybe we
setup an NSCollectionView incorrectly or I'm misinterpreting this
information?

-Aaron
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com