Closed Daemonson closed 5 years ago
What is the exception code? Sounds like a 0x8badf00d
caused by some deadlock...
You misunderstand me. When I say “exception code”, I’m not talking about your source code, but rather the hexadecimal numeric code generated when the app crashed. It’s usually somewhere near the top of the crash report. See Understanding and Analyzing Application Crash Reports: Exception Information.
@robertmryan Thanks for your help. Here is my exception code:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001c520b04c
Triggered by Thread: 0
Ok. That’s not a deadlock. (I.e., it’s not one of those pre-defined codes outlined in that document, such as 0x8badf00d
).
The EXC_BREAKPOINT
is generally a sign that it’s trying to tell the debugger where the issue was. Not surprisingly, this is what happens if you’re using the debugger and there was some breakpoint. But in a release build running alone on a device, it’s generally the sign that some exception was thrown (and in the absence of a debugger, you get this crash log).
So what I do in these cases, is I backtrack in the stack trace of the crashed thread and look for the name of one of my methods. In your case, it looks like it’s in -[SQDCDBManager queryTotalCount:]
(I’m assuming that’s some code that you or someone in your team wrote.) Take a look at that method (assuming I identified the right one) and see if there’s some edge case that could cause some catastrophic scenario.
Is that routine doing an executeUpdate
? Can you share that with us?
@robertmryan I am very grateful for your analysis and help. Here are the codes of the function queryTotalCount
.
We use this function to get the data count from the DB. We have analyzed this function several times and no crash was caused by this function before.
- (void)queryTotalCount:(void(^)(NSUInteger count))block {
__block int totalCount = 0;
[self.fmDbQueue inTransaction:^(FMDatabase * _Nonnull db, BOOL * _Nonnull rollback) {
NSString* sql = [NSString stringWithFormat:@"SELECT COUNT(*) FROM %@", @"BigData"];
FMResultSet *s = [db executeQuery:sql];
if ([s next]) {
totalCount = [s intForColumnIndex:0];
}
dispatch_async(dispatch_get_main_queue(), ^{
SQSafeBlock(block,totalCount);
});
if ([db hasOpenResultSets]) {
[s close];
}
}];
}
I don't see anything jumping out at me- but one thing I'd do is close the result set right after the totalCount = [s intForColumnIndex:0];
. There's no need to check hasOpenResultSets
, and if you're in a multithreaded environment then that might even cause problems.
I don't see anything jumping out at me- but one thing I'd do is close the result set right after the
totalCount = [s intForColumnIndex:0];
. There's no need to checkhasOpenResultSets
, and if you're in a multithreaded environment then that might even cause problems.
Thanks, I understand the problems you point out. I will correct my code and do some test. But what puzzles me is that once the user encounters this crash, they can no longer launch the app, and they will crash every time. Is it possible that the database was destroyed?
@Daemonson - Nothing is jumping out at me, either. I’m not sure why you’re using inTransaction
, though, as you’re not doing any updates. I’d just use inDatabase
. I can’t imagine that it would cause a problem, but seems unnecessary/inefficient. Admittedly, I’ve never tried doing a transaction and committing it when there weren’t any updates...
@ccgus - I’m a bit surprised to see executeUpdate
in his stack trace, though. Do you know why that’s there? On the basis of the provided code snippet for queryTotalCount
, I would have expected to see executeQuery
, if anything...
beginTransaction
calls executeUpdate
to run the begin exclusive transaction
query. So the SELECT COUNT(*)
is probably never even called.
I wonder if this is a case of the disk being locked or something along those lines?
Maybe try inDatabase
?
... But what puzzles me is that once the user encounters this crash, they can no longer launch the app, and they will crash every time. Is it possible that the database was destroyed?
I wonder if it’s getting corrupted somehow. Do you have any lengthy updates that might leave the database in an inconsistent state if interrupted? Perhaps wrap those in a beginBackgroundTaskWithName:expirationHandler:
?
(As an aside, @ccgus, should the inDatabase
and inTransaction
methods do that beginBackgroundTaskWithName
themselves on iOS, to help minimize corruption?)
beginTransaction
callsexecuteUpdate
to run thebegin exclusive transaction
query. So theSELECT COUNT(*)
is probably never even called.I wonder if this is a case of the disk being locked or something along those lines?
Maybe try
inDatabase
?
Thanks,I will try it.
@robertmryan I'm not sure what you're referring to with beginBackgroundTaskWithName
? Do you mean those methods should call it automatically?
Yeah, I’m wondering whether inTransaction
(and executeUpdate
) should automatically call beginBackgroundTaskWithName
when starting update, and call endBackgroundTask
when done, as outlined in Extending Your App's Background Execution Time. It seems like a very simple way of mitigating potential database corruption.
@robertmryan The way that you said of mitigating potential database corruption is useful. In some cases, the process of performing the executeUpdate
operation may be interrupted and may cause database corruption. But I want to know why the database is corrupted causing the user to crash at the code of the executeUpdate
each time the app is launching. Should I use this function - (BOOL)executeUpdate:(NSString*)sql values:(NSArray *)values error:(NSError * __autoreleasing *)error
to execute update and do something when capture an error? I wonder know what kind of error can cause database corruption and how to fix this kind of error. Delete the corrupted database or do something else?
The code of my executeUpdate
:
- (void)saveReportData:(NSString *)data {
[self.fmDbQueue inTransaction:^(FMDatabase * _Nonnull db, BOOL * _Nonnull rollback) {
NSString *sql = [NSString stringWithFormat:@"insert into BigData (eventJson) values ('%@')", data];
NSError * error;
BOOL validate = [db validateSQL:sql error:&error];
if ([db isOpen] && validate) {
[db executeUpdate:sql];
}
}];
}
Exception Code:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001994af04c
Triggered by Thread: 0
Stack trace:
# Date: 2019-09-05T08:32:00Z
# OS Version: 12.4.0 (16G77)
# Device: iPhone 7 Plus
# RAM Free: 5.8%
# Disk Free: 23.9%
#0. Crashed: fmdb.<FMDatabaseQueue: 0x283dc9830>
0 libsystem_platform.dylib 0x20927f04c _os_unfair_lock_unowned_abort + 36
1 libsystem_platform.dylib 0x2092804f4 _os_unfair_lock_unlock_slow + 144
2 libsqlite3.dylib 0x209a6ef18 sqlite3_snprintf + 3188
3 libsqlite3.dylib 0x209a6eb18 sqlite3_snprintf + 2164
4 libsqlite3.dylib 0x209ad1c0c sqlite3_free_table + 49564
5 libsqlite3.dylib 0x209ad547c sqlite3_free_table + 64012
6 libsqlite3.dylib 0x209ad4c30 sqlite3_free_table + 61888
7 libsqlite3.dylib 0x209aafd00 sqlite3_step + 29564
8 libsqlite3.dylib 0x209aa8b40 sqlite3_step + 444
9 MyAppName 0x1066a0ff4 -[FMDatabase executeUpdate:error:withArgumentsInArray:orDictionary:orVAList:] + 1131 (FMDatabase.m:1131)
10 MyAppName 0x1066a13e0 -[FMDatabase executeUpdate:] + 1222 (FMDatabase.m:1222)
11 MyAppName 0x105415f0c __32-[SQDCDBManager saveReportData:]_block_invoke + 63 (SQDCDBManager.m:63)
12 MyAppName 0x1066a4048 __46-[FMDatabaseQueue beginTransaction:withBlock:]_block_invoke + 230 (FMDatabaseQueue.m:230)
13 libdispatch.dylib 0x2090b17d4 _dispatch_client_callout + 16
14 libdispatch.dylib 0x20905fc1c _dispatch_lane_barrier_sync_invoke_and_complete + 56
15 MyAppName 0x1066a3f20 -[FMDatabaseQueue beginTransaction:withBlock:] + 241 (FMDatabaseQueue.m:241)
16 MyAppName 0x105415e6c -[SQDCDBManager saveReportData:] + 61 (SQDCDBManager.m:61)
17 MyAppName 0x105af9dcc __25+[SQDataCenter saveLogs:]_block_invoke + 146 (SQDataCenter.m:146)
18 libdispatch.dylib 0x2090b0a38 _dispatch_call_block_and_release + 24
19 libdispatch.dylib 0x2090b17d4 _dispatch_client_callout + 16
20 libdispatch.dylib 0x20905f008 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1068
21 CoreFoundation 0x20960432c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
22 CoreFoundation 0x2095ff264 __CFRunLoopRun + 1924
23 CoreFoundation 0x2095fe7c0 CFRunLoopRunSpecific + 436
24 GraphicsServices 0x20b7ff79c GSEventRunModal + 104
25 UIKitCore 0x2360fdc38 UIApplicationMain + 212
26 MyAppName 0x106366580 main + 18 (main.m:18)
27 libdyld.dylib 0x2090c28e0 start + 4
--
#0. Crashed: fmdb.<FMDatabaseQueue: 0x283dc9830>
0 libsystem_platform.dylib 0x20927f04c _os_unfair_lock_unowned_abort + 36
1 libsystem_platform.dylib 0x2092804f4 _os_unfair_lock_unlock_slow + 144
2 libsqlite3.dylib 0x209a6ef18 sqlite3_snprintf + 3188
3 libsqlite3.dylib 0x209a6eb18 sqlite3_snprintf + 2164
4 libsqlite3.dylib 0x209ad1c0c sqlite3_free_table + 49564
5 libsqlite3.dylib 0x209ad547c sqlite3_free_table + 64012
6 libsqlite3.dylib 0x209ad4c30 sqlite3_free_table + 61888
7 libsqlite3.dylib 0x209aafd00 sqlite3_step + 29564
8 libsqlite3.dylib 0x209aa8b40 sqlite3_step + 444
9 MyAppName 0x1066a0ff4 -[FMDatabase executeUpdate:error:withArgumentsInArray:orDictionary:orVAList:] + 1131 (FMDatabase.m:1131)
10 MyAppName 0x1066a13e0 -[FMDatabase executeUpdate:] + 1222 (FMDatabase.m:1222)
11 MyAppName 0x105415f0c __32-[SQDCDBManager saveReportData:]_block_invoke + 63 (SQDCDBManager.m:63)
12 MyAppName 0x1066a4048 __46-[FMDatabaseQueue beginTransaction:withBlock:]_block_invoke + 230 (FMDatabaseQueue.m:230)
13 libdispatch.dylib 0x2090b17d4 _dispatch_client_callout + 16
14 libdispatch.dylib 0x20905fc1c _dispatch_lane_barrier_sync_invoke_and_complete + 56
15 MyAppName 0x1066a3f20 -[FMDatabaseQueue beginTransaction:withBlock:] + 241 (FMDatabaseQueue.m:241)
16 MyAppName 0x105415e6c -[SQDCDBManager saveReportData:] + 61 (SQDCDBManager.m:61)
17 MyAppName 0x105af9dcc __25+[SQDataCenter saveLogs:]_block_invoke + 146 (SQDataCenter.m:146)
18 libdispatch.dylib 0x2090b0a38 _dispatch_call_block_and_release + 24
19 libdispatch.dylib 0x2090b17d4 _dispatch_client_callout + 16
20 libdispatch.dylib 0x20905f008 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1068
21 CoreFoundation 0x20960432c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
22 CoreFoundation 0x2095ff264 __CFRunLoopRun + 1924
23 CoreFoundation 0x2095fe7c0 CFRunLoopRunSpecific + 436
24 GraphicsServices 0x20b7ff79c GSEventRunModal + 104
25 UIKitCore 0x2360fdc38 UIApplicationMain + 212
26 MyAppName 0x106366580 main + 18 (main.m:18)
27 libdyld.dylib 0x2090c28e0 start + 4
#1. com.apple.root.default-qos
0 libsystem_kernel.dylib 0x2092108f4 kevent + 8
1 libsystem_info.dylib 0x2091c1190 _mdns_search_ex + 1972
2 libsystem_info.dylib 0x2091c08f0 _mdns_search + 128
3 libsystem_info.dylib 0x2091bfe94 mdns_addrinfo + 896
4 libsystem_info.dylib 0x2091c5be0 search_addrinfo + 264
5 libsystem_info.dylib 0x2091c9be8 si_addrinfo + 1652
6 libsystem_info.dylib 0x2091bd598 _getaddrinfo_internal + 196
7 libsystem_info.dylib 0x2091bd4c8 getaddrinfo + 52
8 MyAppName 0x1068a8e28 +[WXOMTAGCDAsyncSocket lookupHost:port:error:] + 4333227560
9 MyAppName 0x10689d220 __76-[WXOMTAGCDAsyncSocket connectToHost:onPort:viaInterface:withTimeout:error:]_block_invoke_2 + 4333179424
10 libdispatch.dylib 0x2090b0a38 _dispatch_call_block_and_release + 24
11 libdispatch.dylib 0x2090b17d4 _dispatch_client_callout + 16
12 libdispatch.dylib 0x209055c80 _dispatch_queue_override_invoke + 684
13 libdispatch.dylib 0x209062030 _dispatch_root_queue_drain + 372
14 libdispatch.dylib 0x2090628d4 _dispatch_worker_thread2 + 128
15 libsystem_pthread.dylib 0x2092921b4 _pthread_wqthread + 464
16 libsystem_pthread.dylib 0x209294cd4 start_wqthread + 4
#2. com.apple.Pasteboard.notification-queue
0 libsystem_kernel.dylib 0x20920eee4 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x209289cf8 _pthread_cond_wait$VARIANT$mp + 636
2 Foundation 0x20a03a908 -[__NSOperationInternal _waitUntilFinished:] + 772
3 Foundation 0x209ff53f4 -[__NSObserver _doit:] + 240
4 CoreFoundation 0x2095e3a28 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
5 CoreFoundation 0x2095e39f4 ___CFXRegistrationPost_block_invoke + 64
6 CoreFoundation 0x2095e2ee8 _CFXRegistrationPost + 392
7 CoreFoundation 0x2095e2b94 ___CFXNotificationPost_block_invoke + 96
8 CoreFoundation 0x20955c474 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1496
9 CoreFoundation 0x2095e2644 _CFXNotificationPost + 696
10 Foundation 0x209fcb6f4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
11 Pasteboard 0x21e18dc4c __67+[PBServerConnection beginListeningToPasteboardChangeNotifications]_block_invoke_2
12 libsystem_notify.dylib 0x2092772f4 notify_register_mach_port + 7436
13 libdispatch.dylib 0x20905f7f4 _dispatch_block_async_invoke2 + 104
14 libdispatch.dylib 0x2090b17d4 _dispatch_client_callout + 16
15 libdispatch.dylib 0x20905a324 _dispatch_lane_serial_drain$VARIANT$mp + 592
16 libdispatch.dylib 0x20905ae40 _dispatch_lane_invoke$VARIANT$mp + 428
17 libdispatch.dylib 0x2090634ac _dispatch_workloop_worker_thread + 596
18 libsystem_pthread.dylib 0x209292114 _pthread_wqthread + 304
19 libsystem_pthread.dylib 0x209294cd4 start_wqthread + 4
#3. Thread
0 libsystem_pthread.dylib 0x209294cd0 start_wqthread + 190
#4. com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0x2092040f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x2092035a0 mach_msg + 72
2 CoreFoundation 0x209604120 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x2095ff030 __CFRunLoopRun + 1360
4 CoreFoundation 0x2095fe7c0 CFRunLoopRunSpecific + 436
5 Foundation 0x209fcceac -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
6 Foundation 0x209fccd3c -[NSRunLoop(NSRunLoop) runUntilDate:] + 96
7 UIKitCore 0x2361e3754 -[UIEventFetcher threadMain] + 136
8 Foundation 0x20a0f9674 __NSThread__start__ + 984
9 libsystem_pthread.dylib 0x2092912c0 _pthread_body + 128
10 libsystem_pthread.dylib 0x209291220 _pthread_start + 44
11 libsystem_pthread.dylib 0x209294cdc thread_start + 4
#5. Thread
0 libsystem_pthread.dylib 0x209294cd0 start_wqthread + 190
#6. Thread
0 libsystem_kernel.dylib 0x20920fb74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x2092921f8 _pthread_wqthread + 532
2 libsystem_pthread.dylib 0x209294cd4 start_wqthread + 4
#7. com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x2092040f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x2092035a0 mach_msg + 72
2 CoreFoundation 0x209604120 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x2095ff030 __CFRunLoopRun + 1360
4 CoreFoundation 0x2095fe7c0 CFRunLoopRunSpecific + 436
5 CFNetwork 0x209c1874c -[__CoreSchedulingSetRunnable runForever] + 216
6 Foundation 0x20a0f9674 __NSThread__start__ + 984
7 libsystem_pthread.dylib 0x2092912c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x209291220 _pthread_start + 44
9 libsystem_pthread.dylib 0x209294cdc thread_start + 4
#8. JavaScriptCore bmalloc scavenger
0 libsystem_kernel.dylib 0x20920eee4 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x209289cf8 _pthread_cond_wait$VARIANT$mp + 636
2 libc++.1.dylib 0x2087e5090 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 24
3 JavaScriptCore 0x210892de0 void std::__1::condition_variable_any::wait<std::__1::unique_lock<bmalloc::Mutex> >(std::__1::unique_lock<bmalloc::Mutex>&) + 108
4 JavaScriptCore 0x210896dd4 bmalloc::Scavenger::threadRunLoop() + 176
5 JavaScriptCore 0x21089654c bmalloc::Scavenger::Scavenger(std::__1::lock_guard<bmalloc::Mutex>&) + 10
6 JavaScriptCore 0x210897f8c std::__1::__thread_specific_ptr<std::__1::__thread_struct>::set_pointer(std::__1::__thread_struct*) + 38
7 libsystem_pthread.dylib 0x2092912c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x209291220 _pthread_start + 44
9 libsystem_pthread.dylib 0x209294cdc thread_start + 4
#9. WebThread
0 libsystem_kernel.dylib 0x20920eee4 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x209289cf8 _pthread_cond_wait$VARIANT$mp + 636
2 JavaScriptCore 0x21085988c WTF::ThreadCondition::timedWait(WTF::Mutex&, WTF::WallTime) + 80
3 JavaScriptCore 0x210840514 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 2004
4 JavaScriptCore 0x2108307b4 WTF::LockAlgorithm<unsigned char, (unsigned char)1, (unsigned char)2, WTF::EmptyLockHooks<unsigned char> >::lockSlow(WTF::Atomic<unsigned char>&) + 232
5 WebCore 0x2122ef66c _WebThreadLock() + 264
6 WebCore 0x2122f21f0 WebRunLoopLock(__CFRunLoopObserver*, unsigned long, void*) + 44
7 CoreFoundation 0x209603d08 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
8 CoreFoundation 0x2095fea30 __CFRunLoopDoObservers + 412
9 CoreFoundation 0x2095ff190 __CFRunLoopRun + 1712
10 CoreFoundation 0x2095fe7c0 CFRunLoopRunSpecific + 436
11 WebCore 0x2122f1fc4 RunWebThread(void*) + 600
12 libsystem_pthread.dylib 0x2092912c0 _pthread_body + 128
13 libsystem_pthread.dylib 0x209291220 _pthread_start + 44
14 libsystem_pthread.dylib 0x209294cdc thread_start + 4
#10. MainRunloopMonitor
0 libsystem_kernel.dylib 0x209204148 semaphore_timedwait_trap + 8
1 libdispatch.dylib 0x209053888 _dispatch_sema4_timedwait$VARIANT$mp + 64
2 libdispatch.dylib 0x2090541dc _dispatch_semaphore_wait_slow + 72
3 MyAppName 0x1070550cc -[BLYMainRunloopMonitorManager monitorThreadRun] + 45524
4 Foundation 0x20a0f9674 __NSThread__start__ + 984
5 libsystem_pthread.dylib 0x2092912c0 _pthread_body + 128
6 libsystem_pthread.dylib 0x209291220 _pthread_start + 44
7 libsystem_pthread.dylib 0x209294cdc thread_start + 4
#11. com.twitter.crashlytics.ios.MachExceptionServer
0 MyAppName 0x1070a5d98 CLSProcessRecordAllThreads + 376480
1 MyAppName 0x1070a6180 CLSProcessRecordAllThreads + 377480
2 MyAppName 0x1070959f8 CLSHandler + 310016
3 MyAppName 0x107090dd8 CLSMachExceptionServer + 290528
4 libsystem_pthread.dylib 0x2092912c0 _pthread_body + 128
5 libsystem_pthread.dylib 0x209291220 _pthread_start + 44
6 libsystem_pthread.dylib 0x209294cdc thread_start + 4
#12. NSOperationQueue 0x2833e9540 (QOS: UNSPECIFIED)
0 libsystem_kernel.dylib 0x2092040f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x2092035a0 mach_msg + 72
2 CoreFoundation 0x209604120 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x2095ff030 __CFRunLoopRun + 1360
4 CoreFoundation 0x2095fe7c0 CFRunLoopRunSpecific + 436
5 Foundation 0x209fcceac -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
6 MyAppName 0x1069f14a0 -[AMapMacFinderPingOperation start] + 488548
7 Foundation 0x20a0d9c4c __NSOQSchedule_f + 272
8 libdispatch.dylib 0x2090b0a38 _dispatch_call_block_and_release + 24
9 libdispatch.dylib 0x2090b17d4 _dispatch_client_callout + 16
10 libdispatch.dylib 0x20905601c _dispatch_continuation_pop$VARIANT$mp + 412
11 libdispatch.dylib 0x2090556e0 _dispatch_async_redirect_invoke + 600
12 libdispatch.dylib 0x209062030 _dispatch_root_queue_drain + 372
13 libdispatch.dylib 0x2090628d4 _dispatch_worker_thread2 + 128
14 libsystem_pthread.dylib 0x2092921b4 _pthread_wqthread + 464
15 libsystem_pthread.dylib 0x209294cd4 start_wqthread + 4
#13. io.answers.EventQueue (QOS: BACKGROUND)
0 libsystem_kernel.dylib 0x209210a38 listxattr + 8
1 Foundation 0x20a09f894 _attributesAtPath + 60
2 Foundation 0x20a007158 +[NSFileAttributes _attributesAtPath:partialReturn:filterResourceFork:error:] + 336
3 MyAppName 0x1070b3914 +[ANSFileUtils fileSizeAtURL:] + 432668
4 MyAppName 0x1070bf8f8 -[ANSUploadOperation main] + 481792
5 Foundation 0x209fe37c8 -[__NSOperationInternal _start:] + 740
6 Foundation 0x20a0d9c4c __NSOQSchedule_f + 272
7 libdispatch.dylib 0x2090b0a38 _dispatch_call_block_and_release + 24
8 libdispatch.dylib 0x2090b17d4 _dispatch_client_callout + 16
9 libdispatch.dylib 0x20905601c _dispatch_continuation_pop$VARIANT$mp + 412
10 libdispatch.dylib 0x2090556e0 _dispatch_async_redirect_invoke + 600
11 libdispatch.dylib 0x209062030 _dispatch_root_queue_drain + 372
12 libdispatch.dylib 0x2090628d4 _dispatch_worker_thread2 + 128
13 libsystem_pthread.dylib 0x2092921b4 _pthread_wqthread + 464
14 libsystem_pthread.dylib 0x209294cd4 start_wqthread + 4
#14. com.apple.CoreLocation.0x155d44060
0 libsystem_kernel.dylib 0x209204148 semaphore_timedwait_trap + 8
1 libdispatch.dylib 0x209053888 _dispatch_sema4_timedwait$VARIANT$mp + 64
2 libdispatch.dylib 0x2090541dc _dispatch_semaphore_wait_slow + 72
3 CoreLocation 0x2104166cc CLClientInvalidate + 896
4 CoreLocation 0x21041b7d4 CLClientStopVehicleHeadingUpdates + 1668
5 CoreLocation 0x210474e4c CLGetControlPlaneStatusReport + 40940
6 CoreLocation 0x210474d78 CLGetControlPlaneStatusReport + 40728
7 CoreLocation 0x21046fca4 CLGetControlPlaneStatusReport + 20036
8 CoreLocation 0x21046fb5c CLGetControlPlaneStatusReport + 19708
9 CoreLocation 0x210471e98 CLGetControlPlaneStatusReport + 28728
10 libxpc.dylib 0x2092c9afc _xpc_connection_call_event_handler + 68
11 libxpc.dylib 0x2092c9e60 _xpc_connection_mach_event + 856
12 libdispatch.dylib 0x2090b1894 _dispatch_client_callout4 + 16
13 libdispatch.dylib 0x2090695c0 _dispatch_mach_msg_invoke$VARIANT$mp + 340
14 libdispatch.dylib 0x20905a1f0 _dispatch_lane_serial_drain$VARIANT$mp + 284
15 libdispatch.dylib 0x20906a1cc _dispatch_mach_invoke$VARIANT$mp + 476
16 libdispatch.dylib 0x20905a1f0 _dispatch_lane_serial_drain$VARIANT$mp + 284
17 libdispatch.dylib 0x20905ae40 _dispatch_lane_invoke$VARIANT$mp + 428
18 libdispatch.dylib 0x2090634ac _dispatch_workloop_worker_thread + 596
19 libsystem_pthread.dylib 0x209292114 _pthread_wqthread + 304
20 libsystem_pthread.dylib 0x209294cd4 start_wqthread + 4
#15. Thread
0 libsystem_pthread.dylib 0x209294cd0 start_wqthread + 190
#16. Thread
0 libsystem_kernel.dylib 0x20920fb74 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x2092921f8 _pthread_wqthread + 532
2 libsystem_pthread.dylib 0x209294cd4 start_wqthread + 4
#17. com.apple.CFSocket.private
0 libsystem_kernel.dylib 0x20920f328 __select + 8
1 CoreFoundation 0x20960ce04 __CFSocketManager + 620
2 libsystem_pthread.dylib 0x2092912c0 _pthread_body + 128
3 libsystem_pthread.dylib 0x209291220 _pthread_start + 44
4 libsystem_pthread.dylib 0x209294cdc thread_start + 4
#18. com.analysys.serialQueue
0 libsystem_kernel.dylib 0x20920f9d4 __ulock_wait + 8
1 libdispatch.dylib 0x209053a5c _dispatch_ulock_wait + 56
2 libdispatch.dylib 0x209053b94 _dispatch_thread_event_wait_slow$VARIANT$mp + 48
3 libdispatch.dylib 0x20905fec0 __DISPATCH_WAIT_FOR_QUEUE__ + 328
4 libdispatch.dylib 0x20905fad8 _dispatch_sync_f_slow + 140
5 MyAppName 0x1077e5844 +[NSThread(ANSHelper) AnsRunOnMainThread:] + 1285324
6 MyAppName 0x1077f5564 +[ANSFileManager saveUserDefaultWithKey:value:] + 1350124
7 MyAppName 0x1077e1280 -[AnalysysSDK isAppKeyChanged:] + 1267464
8 MyAppName 0x1077dd1a8 __31-[AnalysysSDK startWithConfig:]_block_invoke_2 + 1250864
9 libdispatch.dylib 0x2090b0a38 _dispatch_call_block_and_release + 24
10 libdispatch.dylib 0x2090b17d4 _dispatch_client_callout + 16
11 libdispatch.dylib 0x20905a324 _dispatch_lane_serial_drain$VARIANT$mp + 592
12 libdispatch.dylib 0x20905ae40 _dispatch_lane_invoke$VARIANT$mp + 428
13 libdispatch.dylib 0x2090634ac _dispatch_workloop_worker_thread + 596
14 libsystem_pthread.dylib 0x209292114 _pthread_wqthread + 304
15 libsystem_pthread.dylib 0x209294cd4 start_wqthread + 4
@Daemonson It'd be interesting to take a look at one of the corrupted databases if you can get ahold of it.
@robertmryan I'm on board with adding beginBackgroundTaskWithName
.
How should we come up with the name, and what to use for expirationHandler
? Should name just be a description of the database, or a UUID? Should it be configurable as a property on a database pool? Just thinking out loud.
I have the similar crash, can you tell me how to resolve it,The error like this
Crashed: io.growing 0 libsystem_platform.dylib 0x1b49c704c _os_unfair_lock_unowned_abort + 36 1 libsystem_platform.dylib 0x1b49c84f4 _os_unfair_lock_unlock_slow + 144 2 libsqlite3.dylib 0x1b51b6f18 sqlite3_snprintf + 3188 3 libsqlite3.dylib 0x1b51b6b18 sqlite3_snprintf + 2164 4 libsqlite3.dylib 0x1b51b4f88 sqlite3_vfs_find + 5548 5 libsqlite3.dylib 0x1b51b1844 sqlite3_open_v2 + 2656 6 SugarChat 0x1022a4408 -[FMG3Database open] + 138 (FMG3Database.m:138) 7 SugarChat 0x102298d44 -[GrowingEventDataBase performDataBaseBlock:] + 421 (GrowingEventDataBase.m:421) 8 SugarChat 0x1022998e4 -[GrowingEventDataBase flush] + 596 (GrowingEventDataBase.m:596) 9 SugarChat 0x102297b24 -[GrowingEventDataBase setValue:forKey:error:] + 276 (GrowingEventDataBase.m:276) 10 SugarChat 0x1022c4300 -[GrowingEventManager writeToDBWithEvent:] + 628 (GrowingEventManager.m:628) 11 SugarChat 0x1022c3dc4 __35-[GrowingEventManager handleEvent:]_block_invoke.351 + 576 (GrowingEventManager.m:576) 12 libdispatch.dylib 0x1b47f8a38 _dispatch_call_block_and_release + 24 13 libdispatch.dylib 0x1b47f97d4 _dispatch_client_callout + 16 14 libdispatch.dylib 0x1b47a2324 _dispatch_lane_serial_drain$VARIANT$mp + 592 15 libdispatch.dylib 0x1b47a2e40 _dispatch_lane_invoke$VARIANT$mp + 428 16 libdispatch.dylib 0x1b47ab4ac _dispatch_workloop_worker_thread + 596 17 libsystem_pthread.dylib 0x1b49da114 _pthread_wqthread + 304 18 libsystem_pthread.dylib 0x1b49dccd4 start_wqthread + 4
@Daemonson @ccgus @robertmryan
Some of our users encountered lots of crash in Fmdb queue. These devices iOS versions are iOS 12.4.0 and iOS 12.3.1. Device models are like iPhone 7, iPhone 7Plus and iPhone 6Plus. We found these users almost can't startup the app, cause the crash happened before the app launch. They try and try many times. But the crash still happened. I don't know if the crash is caused by Fmdb. And we can't reproduce this crash in our app. Please give me some clue about this crash. Thanks a lot.
Another stack trace: