Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I crashed while using FMDB/SQLCipher. #841

Closed
Rain-dew opened this issue Jan 4, 2023 · 2 comments
Closed

I crashed while using FMDB/SQLCipher. #841

Rain-dew opened this issue Jan 4, 2023 · 2 comments

Comments

@Rain-dew
Copy link

Rain-dew commented Jan 4, 2023

It happened by accident. Stack as follows
I want to know the reason for the collapse.
Thanks!

Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: FRONTBOARD 2343432205
<RBSTerminateContext| domain:10 code:0x8BADF00D explanation:[application<com.mkwe.uusafe.com.safemail>:2853] failed to terminate gracefully after 5.0s
ProcessVisibility: Background
ProcessState: Running
WatchdogEvent: process-exit
WatchdogVisibility: Background
WatchdogCPUStatistics: (
"Elapsed total CPU time (seconds): 7.920 (user 6.030, system 1.890), 25% CPU",
"Elapsed application CPU time (seconds): 5.246, 17% CPU"
) reportType:CrashLog maxTerminationResistance:Interactive>

Triggered by Thread: 0

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 SQLCipher 0x1056160fc btreeNext + 16
1 SQLCipher 0x10560aec8 sqlite3VdbeExec + 1692
2 SQLCipher 0x10560aec8 sqlite3VdbeExec + 1692
3 SQLCipher 0x1055eb0d4 sqlite3_step + 484
4 FMDB 0x1054585dc -[FMResultSet nextWithError:] + 40
5 SecMail 0x104c08280 -[UUSMCompanyContactService dc_getDBArrayWithdbArray:] + 595 (UUSMCompanyContactService.m:68)
6 SecMail 0x104c09dfc -[UUSMCompanyContactService findContactsDBdata:] + 843 (UUSMCompanyContactService.m:185)
7 SecMail 0x104c09844 __44-[UUSMCompanyContactService downloadDBFile:]_block_invoke_2.95 + 379 (UUSMCompanyContactService.m:168)
8 SecMail 0x104aa3ac4 -[XMCenter xm_execureSuccessBlockWithResponse:forRequest:] + 95 (XMCenter.m:571)
9 SecMail 0x104aa3a54 __46-[XMCenter xm_successWithResponse:forRequest:]_block_invoke + 35 (XMCenter.m:562)
10 libdispatch.dylib 0x19d9d84b4 _dispatch_call_block_and_release + 32
11 libdispatch.dylib 0x19d9d9fdc _dispatch_client_callout + 20
12 libdispatch.dylib 0x19d9e87f4 _dispatch_main_queue_drain + 928
13 libdispatch.dylib 0x19d9e8444 _dispatch_main_queue_callback_4CF + 44
14 CoreFoundation 0x19649a6f8 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16
15 CoreFoundation 0x19647c058 __CFRunLoopRun + 2036
16 CoreFoundation 0x196480ed4 CFRunLoopRunSpecific + 612
17 GraphicsServices 0x1cf782368 GSEventRunModal + 164
18 UIKitCore 0x19895f3d0 -[UIApplication _run] + 888
19 UIKitCore 0x19895f034 UIApplicationMain + 340
20 SecMail 0x104a29c10 main + 71 (main.m:13)
21 dyld 0x1b4aec960 start + 2528

Thread 1:
0 libsystem_pthread.dylib 0x1e3463b90 start_wqthread + 0

Thread 2:
0 libsystem_kernel.dylib 0x1d300241c __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x1e346b06c _pthread_cond_wait + 1232
2 Vss 0x105b8b3a8 ZLoggerSync::executeByThread() + 100
3 Vss 0x105b8b30c threadFunc(void*) + 12
4 libsystem_pthread.dylib 0x1e34646cc _pthread_start + 148
5 libsystem_pthread.dylib 0x1e3463ba4 thread_start + 8

Thread 3:
0 libsystem_kernel.dylib 0x1d300241c __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x1e346b06c _pthread_cond_wait + 1232
2 Vss 0x105bc14c8 UUTask::executeByThread() + 128
3 Vss 0x105bc13c8 threadFunc(void*) + 12
4 libsystem_pthread.dylib 0x1e34646cc _pthread_start + 148
5 libsystem_pthread.dylib 0x1e3463ba4 thread_start + 8

Thread 4 name: com.apple.uikit.eventfetch-thread
Thread 4:
0 libsystem_kernel.dylib 0x1d3001b48 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1d3014008 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x1d3014248 mach_msg_overwrite + 388
3 libsystem_kernel.dylib 0x1d300208c mach_msg + 24
4 CoreFoundation 0x19647aaf0 __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x19647bd34 __CFRunLoopRun + 1232
6 CoreFoundation 0x196480ed4 CFRunLoopRunSpecific + 612
7 Foundation 0x190822334 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8 Foundation 0x19082221c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64
9 UIKitCore 0x198a9433c -[UIEventFetcher threadMain] + 436
10 Foundation 0x19083b808 NSThread__start + 716
11 libsystem_pthread.dylib 0x1e34646cc _pthread_start + 148
12 libsystem_pthread.dylib 0x1e3463ba4 thread_start + 8

Thread 5:
0 libsystem_pthread.dylib 0x1e3463b90 start_wqthread + 0

Thread 6:
0 libsystem_pthread.dylib 0x1e3463b90 start_wqthread + 0

Thread 7:
0 libsystem_kernel.dylib 0x1d300241c __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x1e346b06c _pthread_cond_wait + 1232
2 SecMail 0x104deafb4 Condition::wait(BaseScopedLock&, long) + 287 (condition.h:73)
3 SecMail 0x104deae6c Condition::wait(long) + 55 (condition.h:94)
4 SecMail 0x104de9178 __async_log_thread() + 195 (appender.cc:516)
5 SecMail 0x104debcf4 Thread::start_routine(void*) + 75 (thread.h:413)
6 libsystem_pthread.dylib 0x1e34646cc _pthread_start + 148
7 libsystem_pthread.dylib 0x1e3463ba4 thread_start + 8

Thread 8 name: com.apple.NSURLConnectionLoader
Thread 8:
0 libsystem_kernel.dylib 0x1d3001b48 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1d3014008 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x1d3014248 mach_msg_overwrite + 388
3 libsystem_kernel.dylib 0x1d300208c mach_msg + 24
4 CoreFoundation 0x19647aaf0 __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x19647bd34 __CFRunLoopRun + 1232
6 CoreFoundation 0x196480ed4 CFRunLoopRunSpecific + 612
7 CFNetwork 0x1977d85a8 0x197582000 + 2450856
8 Foundation 0x19083b808 NSThread__start + 716
9 libsystem_pthread.dylib 0x1e34646cc _pthread_start + 148
10 libsystem_pthread.dylib 0x1e3463ba4 thread_start + 8

Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x00000001367e9e98 x1: 0x0000000000000000 x2: 0x00000001081b5400 x3: 0x0000000000000002
x4: 0x0000000000000002 x5: 0x0000000000000000 x6: 0x0000000283869aa0 x7: 0x0000000000000960
x8: 0x00000001081b5480 x9: 0x000000000000000e x10: 0x000000000000000f x11: 0x000000000000000f
x12: 0x0000000000000002 x13: 0x0000000000000000 x14: 0x0000000000000002 x15: 0x0000000105463d60
x16: 0x00000001e346526c x17: 0x7033000105455930 x18: 0x0000000000000000 x19: 0x00000001367e9e98
x20: 0x0000000000000001 x21: 0x0000000281405e50 x22: 0x0000000106a0be10 x23: 0x0000000000000000
x24: 0x00000001367e9df0 x25: 0x00000001367e9610 x26: 0x0000000000000007 x27: 0x0000000000000a07
x28: 0x00000001367e57a0 fp: 0x000000016b3da0e0 lr: 0x000000010560aec8
sp: 0x000000016b3da0d0 pc: 0x00000001056160fc cpsr: 0x60001000
far: 0x0000000287f60000 esr: 0x56000080 Address size fault

Binary Images:
0x1055d8000 - 0x10569ffff SQLCipher arm64 <640aadedfb5b3c1191b0733e9670aa16> /private/var/containers/Bundle/Application/D0F9382F-D2A7-496A-86F2-D542CEC96C91/SecMail.app/Frameworks/SQLCipher.framework/SQLCipher
0x10544c000 - 0x10545ffff FMDB arm64 <5e1ed3fd65f839398ca8f9d2d7fe3f97> /private/var/containers/Bundle/Application/D0F9382F-D2A7-496A-86F2-D542CEC96C91/SecMail.app/Frameworks/FMDB.framework/FMDB
0x104a24000 - 0x10504bfff SecMail arm64 <3c0ce63f9af63927a9c0db43a74b8cd6> /private/var/containers/Bundle/Application/D0F9382F-D2A7-496A-86F2-D542CEC96C91/SecMail.app/SecMail
0x19d9d6000 - 0x19da1cfff libdispatch.dylib arm64e /usr/lib/system/libdispatch.dylib
0x196400000 - 0x1967e5fff CoreFoundation arm64e <5cdc5d9ae5063740b64ebb30867b4f1b> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x1cf781000 - 0x1cf789fff GraphicsServices arm64e /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
0x1985bd000 - 0x199d9afff UIKitCore arm64e <179501b60fc2344ab969b4e3961ebe10> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
0x1b4ad7000 - 0x1b4b5a00f dyld arm64e /usr/lib/dyld
0x1e3463000 - 0x1e346efff libsystem_pthread.dylib arm64e <1aa3a4b6f9e730568c8b4e4dd81312a4> /usr/lib/system/libsystem_pthread.dylib
0x1d3001000 - 0x1d3037ffb libsystem_kernel.dylib arm64e /usr/lib/system/libsystem_kernel.dylib
0x105b74000 - 0x105cd7fff Vss arm64 <527e61d58ed736f09a09602f266fab08> /private/var/containers/Bundle/Application/D0F9382F-D2A7-496A-86F2-D542CEC96C91/SecMail.app/Frameworks/Vss.framework/Vss
0x1907e0000 - 0x191129fff Foundation arm64e /System/Library/Frameworks/Foundation.framework/Foundation
0x197582000 - 0x197949fff CFNetwork arm64e /System/Library/Frameworks/CFNetwork.framework/CFNetwork

EOF

My Codes:


FMDatabase *database = [FMDatabase databaseWithPath:dbPath];
    if (![database open]) {
        return nil;
    }
    [database setKey:UUSMTablePassword];
    NSMutableArray <UUSMContact *>*contacts = [NSMutableArray array];
    //Total Count
    NSUInteger count = [database intForQuery:[NSString stringWithFormat:@"select count(*) from %@",UUSMTableName]];
    int oneFindCount = 600;
    //cycle find
    while (contacts.count < count) {
        NSString *table = [NSString stringWithFormat:@"select * from %@ limit %d offset %lu", UUSMTableName, oneFindCount, contacts.count];
        FMResultSet *resultSet = [database executeQuery:table];
        resultSet = [database executeQuery:table];
        while ([resultSet next]) {
            NSString *emailAddress = [resultSet stringForColumn:@"email"];
            UUSMContact *item = [[UUSMContact alloc] init]; 
            item.userName = [resultSet stringForColumn:@"username"];
            item.userId = [resultSet stringForColumn:@"userid"];
            item.loginName = [resultSet stringForColumn:@"loginname"];
            item.quanpin = [resultSet stringForColumn:@"quanpin"];
            item.emailAddress = emailAddress;
            item.contactType = UUSMContactTypeOrg;
            [contacts addObject:item];
        }
    }
    [database close]; 

@ccgus
Copy link
Owner

ccgus commented Jan 4, 2023

I think the answer is right there in the crash report:

<RBSTerminateContext| domain:10 code:0x8BADF00D explanation:[application<com.mkwe.uusafe.com.safemail>:2853] failed to terminate gracefully after 5.0s

You're also executing the table query twice. Things would probably go faster if you only did it once.

@ccgus ccgus closed this as completed Jan 4, 2023
@Rain-dew
Copy link
Author

Thank you very much for your reply! I solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants