NSXMLParser in background thread crashing
NSXMLParser in background thread crashing
- Subject: NSXMLParser in background thread crashing
- From: "Justin R. Miller" <email@hidden>
- Date: Thu, 22 Feb 2007 09:36:18 -0500
Hello,
I've recently, for performance reasons and in order to not block the
main UI thread, moved some XML parsing to a background thread. I am
occasionally getting crashes like this:
Thread 6 Crashed:
0 <<00000000>> 0x3e140008 0 + 1041498120
1 libxml2.2.dylib 0x92c954c8
xmlSubstituteEntitiesDefault + 1760
2 libxml2.2.dylib 0x92ca1aa8 xmlParseStartTag + 5708
3 libxml2.2.dylib 0x92ca42ec xmlParseDocument + 3368
4 libxml2.2.dylib 0x92c88c0c xmlParseChunk + 424
5 com.apple.Foundation 0x92a29278 -[NSXMLParser parse] + 236
I need to determine what the problem is here, and I see it as two
possibilities:
1) The XML is causing the parser to crash (seems unlikely).
2) There is something related to threading that is causing this.
I have subclassed NSXMLParser to add an autorelease pool to the
'parse' method. This is the method that I fire off in the background
thread.
- (BOOL)parse
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
BOOL status = [super parse];
[pool release];
return status;
}
The NSXMLParser delegate is the object that creates the thread and it
has the following methods implemented, which all fire when appropriate:
- (void)parserDidEndDocument:(NSXMLParser *)parser
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)
parseError
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)
elementName
namespaceURI:(NSString *)
namespaceURI
qualifiedName:(NSString *)
qualifiedName
attributes:(NSDictionary
*)attributeDict
Am I missing something obvious here?
--
Justin R. Miller
Code Sorcery Workshop
http://codesorcery.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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