SQLite Forum

SIGBUS in sqlite
Login
Hi all. We're currently on SQLite 3.28, and we've been noticing rare SIGBUS errors blaming within SQLite code. The stack trace tends to look like this:

memset
walIndexAppend
walIndexReadHdr
walTryBeginRead
sqlite3PagerSharedLock
sqlite3BtreeBeginTrans
sqlite3VdbeExec
sqlite3_step

In our case, we manipulate the same db, which located in android external storage, whithin multiple processes. And the external storage has plenty of free space left.
After I read the source code, I think it maybe a concurrent problem.
the case I guess is below:
processs A mmap 32kb memory to *-shm file. process B close the db, leads to all advisory locks within db file are released. process C open db and truncate *-shm file because all locks are released.
Meanwhile, process A access memmory which correspond to *-shm file. process A Crash.

In our case, process run normally before access 4096-th byte and crash when access 4096-th byte. So the first page(4k) in mmap is valid. And sqlite would truncate *-shm file to 3 bytes. This make us skeptical.

Could the method using sqlite be correct that multiple process manipulate the same db, such as process A, B open db, process B close, process C open...?
Could potentially the case above we guess occur ?
Could this potentially be a bug in SQLite that we can help triage?

Thank you!

Liziqi