I have the following program which creates a Berkeley DB environment.
#include <db.h>
#include <stdio.h>
int main()
{
DB_ENV *env=NULL;
DB* m_db=NULL;
if(db_env_create(&env,0)==-1) printf("fail create\n");
env->set_lk_max_locks(env, 100000);
env->set_lk_max_lockers(env, 100000);
env->set_lk_max_objects(env, 100000);
if(env->open(env,"/tmp/cc", DB_INIT_MPOOL | DB_INIT_CDB, 0)!=0)
{
printf("No env, creating one\n");
if(env->open(env, "/tmp/cc", DB_CREATE | DB_INIT_MPOOL | DB_INIT_CDB, 0) == -1)
printf("Failed creating env\n");
}
env->close(env,0);
return 0;
}
If you delete the /tmp/cc/__db.002 file (which is one of the indexes Berkeley DB creates), and re-run the program, it will get a SIGBUS when opening the environment (tries to map a non-existent file). Is there any way to avoid this using their API or is this a bug?