I'm writing some sqlite3 code in iOS for the first time. Every time I try and close the sqlite3 database connection with sqlite3_close_v2(db) where db is a sqlite3 * obtained from a call to sqlite2_open_v2, the application crashes with no helpful console output or other information but only on an actual device - it doesn't crash in the simulator.
Here's a code sample:
sqlite3_stmt *statement = NULL;
int returnCode = 0;
if((returnCode = sqlite3_prepare_v2(db, [query UTF8String], (int)strlen([query UTF8String])+1, &statement, NULL)) != SQLITE_OK || statement == NULL) {
Log(@"Failed to create query. code:%d",returnCode);
sqlite3_close_v2(db);
}
The code will crash on the last line in the if statement when I pass a bad query. The code will not crash on the simulator, but it will crash on both an iOS 8 iPad and an iOS 7 iPod.
The crash is reported like this (this is not my own breakpoint, by the way):
dyld`dyld_fatal_error:
-> 0x1200e5088 <+0>: brk #0x3
The breakpoint indicator says the crash is Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1200e5088).
Can anyone help me debug this? I've spent a lot of time googling around to no avail. For now, I'm going to just use sqlite3_close(db), as this does not crash, but I'm worried about any consequences of using the v2 open method with the non-v2 close method...
Aucun commentaire:
Enregistrer un commentaire