• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSXMLDocument Crashing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSXMLDocument Crashing


  • Subject: Re: NSXMLDocument Crashing
  • From: Brad Miller <email@hidden>
  • Date: Wed, 29 Aug 2007 01:05:12 -0700

Thanks for the suggestion Ken. I probably should have mentioned that I tried that already. My user who can get the crash to happen a couple times a day still got the crash.

I might have actually fixed it, running the xml tidy option seems to clean up the entities, but I ran into another issue with it. If the xml contains "[...]" inside of a CDATA (which WordPress likes to do in its RSS feeds), the next < sign gets encoded. So if you have the string "<description><![CDATA[Remember a long time ago [...]]]></ description><content:encoded>" it gets turned into "<description><Remember a long time ago [...]>&lt;/description> &lt;content:encoded>" and some other < signs get encoded after that too. This then cascades into other errors when the parse happens due to tags not matching.

To work around that issue, I'm only doing the tidy if the xml does not contain the string "[...]". So the tidy might be fixing the crash in most feeds, but a few might still be slipping through due to the workaround.

Thanks,

Brad


On Aug 29, 2007, at 12:02 AM, Ken Tozier wrote:

Hi Brad

A few weeks back I was having strange crashes with data returned from NSURLConnection and found the following code worked for me. My errors seemed to be encoding related, so this may not work in your case, but it's worth a shot. Depending on what lives at the URL (HTML or XML) you might want to replace "NSXMLDocumentTidyHTML " with "NSXMLDocumentTidyXML"

NSXMLDocument *queryResult = [[NSXMLDocument alloc] initWithContentsOfURL: testURL
options: NSXMLDocumentTidyHTML
error: &err];


HTH

Ken


On Aug 28, 2007, at 9:40 PM, Brad Miller wrote:

Hi,

I'm getting a crash when creating an NSXMLDocument. It appears that having an unknown entity in the xml data is the trigger. It doesn't happen all of the time though, I'm getting it maybe 1 out of 100 tries. The two times I've caught it, the xml had an unknown/bad entity in it (one was eacute and the other an un- escaped &). So I think that's what's triggering the crash inside of libxml. The stack trace I'm getting on the crash is:

Thread 0 Crashed:
0 libobjc.A.dylib 0x90a594c7 objc_msgSend + 23
1 libxml2.2.dylib 0x91bf6fab __xmlRaiseError + 966
2 libxml2.2.dylib 0x91c042bf xmlParseExternalID + 1084
3 libxml2.2.dylib 0x91c04592 xmlParseDocTypeDecl + 357
4 libxml2.2.dylib 0x91bec2e2 xmlParseChunk + 5055
5 libxml2.2.dylib 0x91c870e3 xmlUCSIsCatZs + 2205
6 libxml2.2.dylib 0x91be6482 xmlTextReaderRead + 265
7 com.apple.Foundation 0x928691b0 -[NSXMLTreeReader parse] + 108
8 com.apple.Foundation 0x9286883c -[NSXMLDocument initWithData:options:error:] + 964
9 com.CynicalPeak.Cyndicate 0x00010685 -[IRConnection parseData] + 369 (IRConnection.m:810)
10 com.CynicalPeak.Cyndicate 0x0000ec05 -[IRConnection connectionDidFinishLoading:] + 28



The xml data is being loaded from the internet using an NSURLConnection. When the connectionDidFinishLoading: callback is received I'm simply taking the data that was received and calling doc = [[NSXMLDocument alloc] initWithData:data options:nil error:&err];


Does anyone have any ideas or suggestions for fixing the crash?

Thanks,

Brad
_______________________________________________

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:
40comcast.net


This email sent to email@hidden

_______________________________________________

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

_______________________________________________

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


References: 
 >NSXMLDocument Crashing (From: Brad Miller <email@hidden>)
 >Re: NSXMLDocument Crashing (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: seemingly simple Core Data fetch question
  • Next by Date: Hillegas printing Stuck again!!
  • Previous by thread: Re: NSXMLDocument Crashing
  • Next by thread: seemingly simple Core Data fetch question
  • Index(es):
    • Date
    • Thread