Re: Crash in -[NSString(NSStringDrawing) drawInRect:withAttributes:] on 10.3.9
Re: Crash in -[NSString(NSStringDrawing) drawInRect:withAttributes:] on 10.3.9
- Subject: Re: Crash in -[NSString(NSStringDrawing) drawInRect:withAttributes:] on 10.3.9
- From: "Shawn Erickson" <email@hidden>
- Date: Thu, 31 Aug 2006 10:26:02 -0700
On 8/22/06, Shawn Erickson <email@hidden> wrote:
Didn't hit anything when I searched but I am wondering if anyone else
has seen a periodic crash down in -[NSString(NSStringDrawing)
drawInRect:withAttributes:] when running on 10.3.9 (doesn't happen on
10.4 and we only support 10.3.9 and later with our products).
The crash doesn't happen very often but when it does it always happens
in the fashion outlined in the backtrace below (in one of the two uses
of drawInRect:withAttributes: in my code). Reviewing code outside of
the below we see no way for any incorrect state for rightText,
leftText, or font (all ivars with related setters, we copy the strings
and textArea is a constant), also walked thru it many times in the
debugger.
Saw a similar crash to one I reported about before but in a totally
different pathway, one in nib loaded UI with only Apple classes
involved... other then a data source used by the table involved (see
backtrace below). As best I can tell AppKit on 10.3.x is mismanaging
NSAttributeDictionary instances that it creates inside AppKit code
related attributed strings. So far the trigger (again it doesn't
always happen) always appears to involve attributed strings that have
an attribute dictionary with a font entry (NSFontAttributeName) but
this trend is based on a limited number of crashes.
Note that all of the pathways that have crashed so far are working
with attributed strings that are created using the following category
method with the supplied string and attribute dictionary both non-nil
and memory managed correctly (usually created on the spot using class
methods that return an auto-released instances). Note zombie testing
reports no issues with any of the objects I manage in my code just
with an instance of NSAttributeDictionary which appears Apple private.
@implementation NSAttributedString (COLUtilities)
+ (NSAttributedString*) stringWithString:(NSString*)string
attributes:(NSDictionary*)attributes
{
return [[[NSAttributedString alloc] initWithString:string
attributes:attributes] autorelease];
}
@end
Pathways in my code that maintain their own retained references to
attributed strings that are displayed so far have not hit this issue.
To me it looks like an aspect of AppKit on 10.3.x (not seen it on
10.4.6/7 systems) is not properly retaining objects it creates
internally or possibly not niling out references that it isn't
retaining.
After searching for posts about NSAttributeDictionary I found a few
others that have reported issues like mine and at least one other
person that implies a work around is to maintain a retain on the
attributed strings (don't use autoreleased attributed strings created
during draw related code). Of course I cannot yet confirm this work
around... need to change some code and do focused testing.
Thread 0 Crashed:
0 libobjc.A.dylib 0x908611ec objc_msgSend + 0xc
1 com.apple.AppKit 0x97d84a94 -[NSAttributeDictionary
isEqualToDictionary:] + 0x8c
2 com.apple.AppKit 0x97d97e28 attributeDictionaryIsEqual + 0xa4
3 com.apple.CoreFoundation 0x901c7170 __CFSetFindBuckets1 + 0xd8
4 com.apple.CoreFoundation 0x901ce560 CFSetGetValue + 0xc8
5 com.apple.AppKit 0x97dab4a4 -[NSAttributeDictionary
newWithKey:object:] + 0x2dc
6 com.apple.Foundation 0x90a3cc04
-[NSConcreteMutableAttributedString addAttribute:value:range:] + 0xfc
7 com.apple.AppKit 0x97e39dcc coverAttributeString + 0xfc
8 com.apple.AppKit 0x97d96ea0 fastDrawTextCell + 0x4d8
9 com.apple.AppKit 0x97dcc604 _NXDrawTextCell + 0x80
10 com.apple.AppKit 0x97dc61f4 -[NSTextFieldCell
drawInteriorWithFrame:inView:] + 0x184
11 com.apple.AppKit 0x97dc82c8 -[NSTextFieldCell
drawWithFrame:inView:] + 0x13c
12 com.apple.AppKit 0x97d9f4b8 -[NSTableView
drawRow:clipRect:] + 0x330
13 com.apple.AppKit 0x97dd0cac -[NSTableView drawRect:] + 0x378
14 com.apple.AppKit 0x97d79014 -[NSView _drawRect:clip:] + 0x770
15 com.apple.AppKit 0x97d754f0 -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
+ 0x228
16 com.apple.AppKit 0x97d75780 -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
+ 0x4b8
17 com.apple.AppKit 0x97d86658 -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] +
0x180
18 com.apple.AppKit 0x97d9f684 -[NSView displayIfNeeded] + 0xa8
19 com.apple.AppKit 0x97ddc330 -[NSClipView
_immediateScrollToPoint:] + 0x51c
20 com.apple.AppKit 0x97e6fbac -[NSScrollView
scrollClipView:toPoint:] + 0xfc
21 com.apple.AppKit 0x97dc94f0 -[NSClipView
_scrollTo:animate:] + 0x2e8
22 com.apple.AppKit 0x97e0d228 -[NSScrollView
_doScroller:hitPart:multiplier:] + 0x354
23 com.apple.AppKit 0x97e296a8 -[NSApplication
sendAction:to:from:] + 0x6c
24 com.apple.AppKit 0x97e303d0 -[NSControl
sendAction:to:] + 0x60
25 com.apple.AppKit 0x97e84890 -[NSScroller
sendAction:to:] + 0x5c
26 com.apple.AppKit 0x97e2d528 -[NSScroller trackKnob:] + 0x298
27 com.apple.AppKit 0x97ea0774 -[NSScroller mouseDown:] + 0x2c8
28 com.apple.AppKit 0x97db45a0 -[NSWindow sendEvent:] + 0x10e4
29 com.apple.AppKit 0x97da6c4c -[NSApplication
sendEvent:] + 0xebc
30 com.apple.AppKit 0x97daf07c -[NSApplication run] + 0x240
31 com.apple.AppKit 0x97e6b774 NSApplicationMain + 0x1d0
32 blah 0x00002fdc No line number information available for address 0x2fdc
33 blah 0x00002e84 No line number information available for address 0x2e84
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden