Geez. The more I look into the Berkeley DB back end the more fucked up I
find it is. Disregard the previous comment about the locking subsystem.
I changed dbenv->open() flags again, this time
DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN |
DB_RECOVER
| DB_THREAD
Some interesting developments here.
I disabled Berkeley DB's locking subsystem, because Citadel handles locking
and concurrency on its own. This seems to have fixed the segfault when it
closes the database environment. I also have not managed to corrupt the
database
no matter how badly