ccgus / fmdb

A Cocoa / Objective-C wrapper around SQLite
Other
13.85k stars 2.77k forks source link

fmdb crash #761

Open lotawei opened 5 years ago

lotawei commented 5 years ago

when use fmdb like this 。。。

NSString *sqlString = [NSString stringWithFormat:@"SELECT * FROM workout where distance != 0 and duration != 0 and start_time != 0 and end_time != 0 and userID=%d and sport != 8 ORDER BY start_time DESC LIMIT 1 ", userID];
    FMResultSet *rs = [_dataBase executeQuery:sqlString];
    while([rs next]) {  // there will be crash  
    }

and location fmdb crash in this function

- (BOOL)nextWithError:(NSError **)outErr

crashed in int rc = sqlite3_step([_statement statement]);
so i am feel uncertained

ccgus commented 5 years ago

We'll need more information to help diagnose the problem. Stack traces are always helpful.

EmirShayymov commented 3 years ago

Hi, I have similar crash: [self.fmdbConnection inTransaction:^(FMDatabase db, BOOL rollback) { FMResultSet rs = [db executeQuery:@"select 1 from (select count() as a from TABLE1) join (select count(*) as b from MESSAGEINDEX_docsize) on a = b"]; if (![rs next]) // there will be crash { [db executeUpdate:@"INSERT INTO MESSAGEINDEX(MESSAGEINDEX) VALUES('rebuild')"]; } }]; [self.fmdbConnection close];

Stack trace from crashing thread: Thread 4 name: Thread 4: 0 libsystem_kernel.dylib 0x00000001b7c047e0 pread + 8 1 libsqlite3.dylib 0x000000019f933db0 seekAndRead + 76 (sqlite3.c:40142) 2 libsqlite3.dylib 0x000000019f885e50 unixRead + 208 (sqlite3.c:40234) 3 libsqlite3.dylib 0x000000019f8a840c readDbPage + 180 (sqlite3.c:24270) 4 libsqlite3.dylib 0x000000019f93d6d4 getPageNormal + 496 (sqlite3.c:65416) 5 libsqlite3.dylib 0x000000019f947ffc getAndInitPage + 96 (sqlite3.c:65531) 6 libsqlite3.dylib 0x000000019f8c6a4c sqlite3VdbeExec + 20924 (sqlite3.c:0) 7 libsqlite3.dylib 0x000000019f8c08f0 sqlite3_step + 308 (sqlite3.c:92004) 8 MyTarget 0x000000010a4dec44 -[FMResultSet nextWithError:] + 60 (FMResultSet.m:166)

Could you please help what it could be?