Re: EXC_BAD_ACCESS and NSAttributedString driving me crazy
Re: EXC_BAD_ACCESS and NSAttributedString driving me crazy
- Subject: Re: EXC_BAD_ACCESS and NSAttributedString driving me crazy
- From: "email@hidden" <email@hidden>
- Date: Tue, 31 Mar 2009 11:24:38 +0100
On 31 Mar 2009, at 08:16, Ali Ozer wrote:
Likely so, and likely one that's fixed already... But the
workaround is your best bet for now.
Ali
For what it's worth I am occasionally seeing similar behaviour when
writing to the pasteboard.
#pragma warning possible problem here
// Program received signal: “EXC_BAD_ACCESS”. sometimes
generated when dragging within IKBrowserImageView
// get a tiff representation and write to pasteboard
NSImage *image = [[NSImage alloc] initWithData:imageData];
if (image) {
NSData *tiffData = [image TIFFRepresentation];
if (tiffData) {
[pasteboard setData:tiffData forType:NSTIFFPboardType];
itemsWritten++;
} else {
MLog(DEBUGLOG, @"cannot create TIFF representation");
}
} else {
MLog(DEBUGLOG, @"cannot create image");
}
the crash report records:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread: 0
Application Specific Information:
objc[235]: garbage collection is ON
Thread 0 Crashed:
0 com.apple.CoreFoundation 0x9572392b CFDictionaryRemoveValue
+ 43
1 com.apple.AppKit 0x9441bf3a -[NSPasteboard
setData:forType:] + 199
30.Mar.2009 tarihinde 22:32 saatinde, Chris Idou <email@hidden>
şunları yazdı:
That's a good trick to know! When I bracket the calls thus, it
crashes in a different but similar place:
#0 0x95a82688 in objc_msgSend
#1 0x90894910 in processColor
#2 0x9089395b in CharAttr
#3 0x9088db34 in -[NSRTFReader attributedString]
#4 0x9070bc03 in _NSReadAttributedStringFromURLOrData
#5 0x90709943 in -
[NSAttributedString(NSAttributedStringKitAdditions)
initWithData:options:documentAttributes:error:]
#6 0x9088c542 in -
[NSAttributedString(NSAttributedStringKitAdditions)
initWithRTF:documentAttributes:]
#7 0x908e6f25 in +[_NSRTFPboardTypeConverter
pasteboard:provideDataForType:]
#8 0x908e6b58 in __NSPasteboardProvideData
#9 0x918dd120 in __CFPasteboardResolvePromiseForItemLocal
#10 0x918e0680 in CFPasteboardCopyData
#11 0x9086763e in -[NSPasteboard _dataWithoutConversionForType:]
#12 0x9086748a in -[NSPasteboard dataForType:]
And then if I bracket the call to dataForType: as well, the crashes
stop happening. I'm relieved to know I at least have a workaround.
Does this tend to indicate some kind of Apple GC bug?
From: Ali Ozer <email@hidden>
To: Chris Idou <email@hidden>
Cc: Cocoa Dev <email@hidden>
Sent: Tuesday, 31 March, 2009 4:12:55 PM
Subject: Re: EXC_BAD_ACCESS and NSAttributedString driving me crazy
Can you try temporarily disabling garbage collection around the
unarchiving of RTFD, and see if it helps?
[[NSGarbageCollector defaultCollector] disable];
... unarchive your RTFD ...
[[NSGarbageCollector defaultCollector] enable];
Ali
On Mar 30, 2009, at 5:25 PM, Chris Idou wrote:
> I'm getting NSRTFDPboardType and NSRTFPboardType objects as
NSData from the pasteboard and I'm storing them in a core data XML
repository and getting them out again, and when necessary I'm
converting them into NSAttributedString with initWithRTF or
initWithRTFD. This mostly works but every now and then, actually
quite often, this initWithRTF(D) crashes with EXC_BAD_ACCESS.
(stack traces below).
>
> The thing is, I'm doing an md5Hash on the NSData objects every
single time I store them and retrieve them just to make sure they
are not corrupted, and the exact same NSData that is working one
minute as an argument to initWithRTF(D), makes it crash later on.
>
> I'm using garbage collection, but I've solved a lot of GC
problems and this doesn't seem similar.
>
> Has anyone got any thoughts?
>
>
>
>
> #00x95a82688 in objc_msgSend
> #10x933b0b26 in -[NSCFDictionary setObject:forKey:]
> #20x90824684 in -[NSRTFD setObject:forKey:]
> #30x908f3c2f in -[NSAKDeserializer deserializePList:]
> #40x908f3961 in -[NSDocumentDeserializer deserializeNewPList]
> #50x908f3753 in -[NSRTFD(NSSerializationSupport)
initWithPasteboardDataRepresentation:]
> #60x908f2fe9 in -[NSFileWrapper initWithSerializedRepresentation:]
> #70x908f2e32 in -[NSRTFReader initWithRTFD:]
> #80x9070b9a7 in _NSReadAttributedStringFromURLOrData
> #90x90709943 in -
[NSAttributedString(NSAttributedStringKitAdditions)
initWithData:options:documentAttributes:error:]
> #100x908f2de2 in -
[NSAttributedString(NSAttributedStringKitAdditions)
initWithRTFD:documentAttributes:]
> ......
>
> #00x95a82688 in objc_msgSend
> #10x90894910 in processColor
> #20x9089395b in CharAttr
> #30x9088db34 in -[NSRTFReader attributedString]
> #40x9070bc03 in _NSReadAttributedStringFromURLOrData
> #50x90709943 in -
[NSAttributedString(NSAttributedStringKitAdditions)
initWithData:options:documentAttributes:error:]
> #60x9088c542 in -
[NSAttributedString(NSAttributedStringKitAdditions)
initWithRTF:documentAttributes:]
> .....
>
>
> Program received signal: “EXC_BAD_ACCESS”.
>
>
>
> Enjoy a better web experience. Upgrade to the new Internet
Explorer 8 optimised for Yahoo!7. Get it now.
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
The new Internet Explorer 8 optimised for Yahoo!7: Faster, Safer,
Easier. Get it now..
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden
Jonathan Mitchell
Central Conscious Unit
http://www.mugginsoft.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden