I'm having a problem with an instance of an AppKit private class turning into a zombie. I'm on 10.4.1 and this happens building for both 10.4 and using the cross-development SDK to target 10.3 The stack trace is here:
#0 0x92949c40 in -[_NSZombie forward::] #1 0x909b10d0 in _objc_msgForward #2 0x928db0f0 in -[NSDictionary isEqualToDictionary:] #3 0x93676274 in attributeDictionaryIsEqual #4 0x9074868c in __CFSetFindBuckets1b #5 0x90747d28 in CFSetGetValue #6 0x936679e4 in +[NSAttributeDictionary newWithDictionary:] #7 0x92898704 in -[NSConcreteMutableAttributedString setAttributes:range:] #8 0x936f57ac in -[NSConcreteTextStorage setAttributes:range:] #9 0x9289866c in -[NSMutableAttributedString addAttributes:range:] #10 0x00149fbc in -[myTextView changeAttributes:withActionName:]
The line of code in myTextView that is being executed is
[[self textStorage] addAttributes: newAttributes range: selectedRange];
The selectedRange is correct, the newAttributes dictionary has a retainCount of 1 at the time of the call, adding an additional retain/release around the line of code doesn't help. It contains a single entry, for NSShadowAttributeName, an instance of my own subclass of NSShadow. I'm logging the release and dealloc methods of the NSShadow subclass and the instance isn't released along here.
Checking in the debugger, at the point of the call to -[NSDictionary isEqualToDictionary:] its argument is a NSZombie_AttributeDictionary.
Using a category to replace the release method of NSAttributeDictionary with a do-nothing (I know - huge leak, but we're just debugging here) fixes things - no crashes and the code does what it is supposed to do (as it did on Panther).
Anyone have any ideas ? This is a real show-stopper for the app. The work-around is very ugly - set up a global lock and array mechanism, use a category to replace the release method of NSAttributeDictionary (holding on to the original) with one that calls the original if the lock isn't set and just logs the instance for later release if the lock is set then lock it out over this call.
.....TIA,
Bob Clair
|