Things that go bmp in the night...
Things that go bmp in the night...
- Subject: Things that go bmp in the night...
- From: Rainer Brockerhoff <email@hidden>
- Date: Tue, 28 Oct 2003 21:14:26 -0200
I've just survived a hectic period of making my app work correctly with Panther.
I lost several days trying to find the cause of serious crash that happened on Panther but not on Jaguar. Here's a typical stack (edited down for legibility):
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x78901e00
Thread 0 Crashed:
#0 0x90831234 in objc_msgSend (objc_msgSend + 20)
#1 0x909f5524 in isEqualObjectMT (isEqualObjectMT + 52)
#2 0x909f36d8 in __NSMapTableEqual (__NSMapTableEqual + 64)
#3 0x90192fb4 in __CFDictionaryFindBuckets1b (__CFDictionaryFindBuckets1b + 204)
#4 0x901a5b1c in CFDictionaryRemoveValue (CFDictionaryRemoveValue + 220)
#5 0x92e6473c in -[NSCell setMnemonicLocation:] (-[NSCell setMnemonicLocation:] + 288)
#6 0x92e6a3b8 in -[NSMenuItemCell drawTitleWithFrame:inView:] (-[NSMenuItemCell drawTitleWithFrame:inView:] + 560)
#7 0x92e6935c in -[NSMenuItemCell drawInteriorWithFrame:inView:] (-[NSMenuItemCell drawInteriorWithFrame:inView:] + 388)
#8 0x92e691c4 in -[NSMenuItemCell drawWithFrame:inView:] (-[NSMenuItemCell drawWithFrame:inView:] + 244)
#9 0x92e503c4 in -[NSPopUpButtonCell drawWithFrame:inView:] (-[NSPopUpButtonCell drawWithFrame:inView:] + 688)
#10 0x92df7d68 in -[NSControl drawRect:] (-[NSControl drawRect:] + 276)
#11 0x92dc78b0 in -[NSView _drawRect:clip:] (-[NSView _drawRect:clip:] + 1716)
...
#31 0x92dedd84 in -[NSView displayIfNeeded] (-[NSView displayIfNeeded] + 168)
#32 0x92f178e4 in -[NSThemeFrame handleSetFrameCommonRedisplay] (-[NSThemeFrame handleSetFrameCommonRedisplay] + 256)
#33 0x92e21694 in -[NSWindow _setFrameCommon:display:stashSize:] (-[NSWindow _setFrameCommon:display:stashSize:] + 680)
#34 0x92e99358 in -[NSWindow setFrame:display:] (-[NSWindow setFrame:display:] + 44)
#35 0x92efa0c0 in _NSMoveHelperTimerCallBack (_NSMoveHelperTimerCallBack + 608)
#36 0x90194848 in __CFRunLoopDoTimer (__CFRunLoopDoTimer + 244)
#37 0x90191ba8 in __CFRunLoopRun (__CFRunLoopRun + 1480)
#38 0x901960bc in CFRunLoopRunSpecific (CFRunLoopRunSpecific + 328)
#39 0x92ef9d30 in -[NSMoveHelper _doAnimation] (-[NSMoveHelper _doAnimation] + 488)
#40 0x92fa2778 in -[NSMoveHelper _resizeWindow:toFrame:display:] (-[NSMoveHelper _resizeWindow:toFrame:display:] + 176)
#41 0x92f1ef24 in -[NSWindow setFrame:display:animate:] (-[NSWindow setFrame:display:animate:] + 176)
#42 0x00042688 in -[XRayDoc popupAction:] (XRayDoc.m:2049)
#43 0x00041f90 in -[XRayDoc setPopup:] (XRayDoc.m:1984)
...
#47 0x92dfd754 in -[NSApplication run] (-[NSApplication run] + 576)
#48 0x92eb9a1c in NSApplicationMain (NSApplicationMain + 464)
#49 0x00002c04 in main (main.m:48)
Turning on NSZombie options, it seems that objc_msgSend was being called on a deallocated instance of some NSTextField.
After wasting a great deal of time on setting up NSZombie breakpoints, and generally trying to find a double release or something like that, it struck me that I'd never heard about the call in frame #5 (-[NSCell setMnemonicLocation:]).
Looking it up in the docs, I found they say that it's obsolete or not implemented... why then is -[NSMenuItemCell drawTitleWithFrame:inView:] calling it when drawing the title? More puzzling, it's called every time with NSNotFound as the parameter... meaning there's no mnemonic!
And if there's no mnemonic, why is -[NSCell setMnemonicLocation:] checking dictionaries and other stuff? And crashing while removing one of my deallocated objects from a dictionary which should have been always empty to begin with?
I finally gave up and wrote:
@interface NSCellHack: NSCell
@end
@implementation NSCellHack
- (void)setMnemonicLocation:(unsigned)location { }
@end
...
[NSCellHack poseAsClass:[NSCell class]];
after which all crashes magically ceased, with no apparent ill side effects.
Later I had a stab at writing a smaller app to use as a test case for submitting a bug to Apple, with no effect. So before submitting a bug report without any way of reproducing it (short of sending my entire source to Apple) I thought of asking you folks to see if anybody's ever run into setMnemonicLocation... or even heard of it.
Any takers? TIA,
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"Originality is the art of concealing your sources."
http://www.brockerhoff.net/ now with forums for XRay, Zingg! et al.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.