Hi I have a litte confuse about my crash dump information, I put the crash dump's key information as follows, its look like a two threads race condition issue?
The Last Exception Bracktrace and the Thread 16.
In the beginning, I suppose the Last Exception in just the Thread 16. But when I look into more detail. I found a call stack seems a little different. The last the same call stack is
#1 in Last Exception & #8 in thread 16. Then the call stack goes different way.
Here is my code about the -[DataManager saveHistory], the self.saveHistoryLock is what I used to synchronize the threads. So I don't understand why the race condition happened? Did I miss something about the @synchronized or the Last Exception Backtrace is just the thread 16?
Does anybody have any idea to check why the crash happened?
Thanks,
Eric
- (BOOL) saveHistory
{
@synchronized (self.saveHistoryLock) {
if(g_HistoryDirty)
{
NSArray * cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString * archivePath = [[cachePaths lastObject] stringByAppendingPathComponent:@"CalculatorHistory.archive"];
BOOL result = [NSKeyedArchiver archiveRootObject:_historyArray toFile:archivePath];
g_HistoryDirty = FALSE;
return result;
}
return TRUE;
}
}
Last Exception Backtrace(0)
#0 (null) in __exceptionPreprocess ()
#1 (null) in objc_exception_throw ()
#2 (null) in __NSFastEnumerationMutationHandler ()
#3 (null) in -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] ()
#4 (null) in _encodeObject ()
#5 (null) in +[NSKeyedArchiver archiveRootObject:toFile:] ()
#6 (null) in -[DataManager saveHistory] at /Users/PCalculator/Common/DataManager.m:424
#7 (null) in __NSThread__start__ ()
#8 (null) in _pthread_body ()
#9 (null) in _pthread_start ()
#10 (null) in thread_start ()
---------------------------------------------------------------------------------------------------------------------------------------------------------
Thread 16
#0 (null) in __pthread_kill ()
#1 (null) in pthread_kill ()
#2 (null) in abort ()
#3 (null) in abort_message ()
#4 (null) in default_terminate_handler() ()
#5 (null) in _objc_terminate() ()
#6 (null) in std::__terminate(void (*)()) ()
#7 (null) in __cxa_throw ()
#8 (null) in objc_exception_throw ()
#9 (null) in __NSFastEnumerationMutationHandler ()
#10 (null) in -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] ()
#11 (null) in _encodeObject ()
#12 (null) in +[NSKeyedArchiver archiveRootObject:toFile:] ()
#13 (null) in -[DataManager saveHistory] at /Users/PCalculator/Common/DataManager.m:424
#14 (null) in __NSThread__start__ ()
#15 (null) in _pthread_body ()
#16 (null) in _pthread_start ()
#17 (null) in thread_start ()