SQLite freezes while performing sqlite3_step

155 views Asked by At

Our app started logging crash reports caused by a deadlock in SQLite:

Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: RUNNINGBOARD 0xdead10cc

It occurs in the iPhone/iPad version of our app. We use the system's built-in SQLite library and open database with the following settings:

int err = sqlite3_open_v2(db_path, &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_FULLMUTEX, nil);

Reports indicate the app freezes at some non-main thread doing the following:

Thread 2 name:
Thread 2:
0   libsystem_kernel.dylib          0x00000001ea5fcd9c pread + 8 (:-1)
1   libsqlite3.dylib                0x00000001d065a228 seekAndRead + 96 (sqlite3.c:41646)
2   libsqlite3.dylib                0x00000001d05d3078 unixRead + 208 (sqlite3.c:41738)
3   libsqlite3.dylib                0x00000001d05e5e60 readDbPage + 180 (sqlite3.c:64270)
4   libsqlite3.dylib                0x00000001d0663ca8 getPageNormal + 488 (sqlite3.c:66892)
5   libsqlite3.dylib                0x00000001d066f388 getAndInitPage + 100     (sqlite3.c:76131)
6   libsqlite3.dylib                0x00000001d06705f8 moveToLeftmost + 136 (sqlite3.c:79298)
7   libsqlite3.dylib                0x00000001d05f93b4 sqlite3VdbeExec + 5000 (sqlite3.c:102042)
8   libsqlite3.dylib                0x00000001d05f75b4 sqlite3_step + 984 (sqlite3.c:94140)

Some crash reports have this stack:

Thread 3 name:
Thread 3:
0   libsystem_kernel.dylib          0x00000001df2adc88 fsync + 8 (:-1)
1   libsqlite3.dylib                0x00000001c52c7d18 unixSync + 212 (sqlite3.c:42244)
2   libsqlite3.dylib                0x00000001c52d0560 syncJournal + 576 (sqlite3.c:65600)
3   libsqlite3.dylib                0x00000001c52c78a4 sqlite3PagerCommitPhaseOne + 392 (sqlite3.c:67879)
4   libsqlite3.dylib                0x00000001c52b871c sqlite3BtreeCommitPhaseOne + 172 (sqlite3.c:78021)
5   libsqlite3.dylib                0x00000001c52b81ec vdbeCommit + 688 (sqlite3.c:90610)
6   libsqlite3.dylib                0x00000001c5290998 sqlite3VdbeHalt + 1320 (sqlite3.c:91020)
7   libsqlite3.dylib                0x00000001c52b29b4 sqlite3VdbeExec + 43400 (sqlite3.c:99633)
8   libsqlite3.dylib                0x00000001c52a75b4 sqlite3_step + 984 (sqlite3.c:94140)

And even this:

Thread 4 name:
Thread 4:
0   libsqlite3.dylib                0x00000001eb90ef18 accessPayload + 312 (sqlite3.c:78866)
1   libsqlite3.dylib                0x00000001eb8f4634 sqlite3VdbeMemFromBtree + 200 (sqlite3.c:87070)
2   libsqlite3.dylib                0x00000001eb8e9e24 sqlite3VdbeExec + 40440 (sqlite3.c:98870)
3   libsqlite3.dylib                0x00000001eb8df5b4 sqlite3_step + 984 (sqlite3.c:94140)

These are excerpts from different crash logs and don't have any other calls to SQLite lib. We cannot reproduce the crash on debug builds and have no steps to reproduce but are confident it doesn't depend on the query because it occurs in various places throughout the app, performing read-only and modification queries.

How to resolve this issue or where to find the answer? Is there anything I can add to help investigate the issue?

0

There are 0 answers