Random crashes in custom NSOperation
Using iOS 4.3 on an ipad app
I have a custom NSOperation that uses an http request to process fragments of xml the operations are used in an NSOperationQueue. For the most part the app runs fine but, especially when tested on device the app crashes, this is always on a background/separate thread to the main thread. I've had this manifest itself as various errors including the infamous
warning: check_safe_call: could not restore current frame
ive pared back my code and discovered that the start method in my operation appears to be the culprit.
-(void)start
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
self.handledElements = [NSArray arrayWithObjects:@"el1", @"el2", @"el3", nil];
if (![NSThread isMainThread])
{
[self performSelectorOnMainThread:@selector(start) withObject:nil waitUntilDone:NO];
return;
}
// problem is here !!
[self willChangeValueForKey:@"isExecuting"];
_isExecuting = YES;
[self didChangeValueForKey:@"isExecuting"];
context = xmlCreatePushParserCtxt(&simpleSAXHandlerStruct, self, NULL, 0, NULL);
if(_urlIsRelative == YES){
self.request = [[MyHttpRequest alloc] initWithRelativeUrl:self.url andDelegate:self];
}
else {
self.request = [[MyHttpRequest alloc] initWithAbsoluteUrl:self.url andDelegate:self];
}
self.characterBuffer = [[NSMutableData alloc] init];
[self.request startRequest];
[pool drain];
}
the offending line appears to be the willChangeValueForKey:@"isExecuting" if i remove the lines related to KVO i cannot get the app to crash at all, if i add them back in i get random errors that always seem to point to getting the key value observance count. Although my app works, i would rather the start method was written as expected, with the KVO notifications take care of b开发者_运维问答y me, any ideas??
i have a singleton class that observes outputs from each operation – Matt 38 mins ago
.... and that singleton is fully concurrent-safe for the isExecuting change notifications (observations)?
This seems to have been an issue with libxml, i have updated my version and the problem has now gone away...
精彩评论