Hello,
 
I have big troubles using the db_berkeley module in Kamailio version 4.2.2 in combination with presence related modules like presence, presence_xml or rls.
 
Kamailio cannot startup and is "hanging" in the OS (RHEL 6.4 with kernel 2.6.32-358.el6.i686). In the debug modus I can see following log output:
 
[...] kamailio[18400]: INFO: cfgutils [cfgutils.c:784]: mod_init(): no hash_file given, disable hash functionality
[...] kamailio[18400]: INFO: db_berkeley [km_db_berkeley.c:212]: bdb_init(): using database at: /var/lib/berkeley_kamailio42.db
[...] kamailio: ERROR: <core> [daemonize.c:315]: daemonize(): Main process exited before writing to pipe
During startup the OS is creating a core dump. Backtrace analysation of these dumps brought following information (gdb output):
 
(variant 1):
Program terminated with signal 11, Segmentation fault.
#0  0x00ee965b in ?? () from /lib/libdb-4.7.so(gdb) bt
#0  0x00ee965b in ?? () from /lib/libdb-4.7.so
#1  0x00ee9bbc in ?? () from /lib/libdb-4.7.so
#2  0x00eea2a0 in __dbc_get_pp () from /lib/libdb-4.7.so
#3  0x00269a07 in bdb_delete (_h=0xb6f94484, _k=0x0, _op=0x0, _v=0x0, _n=0) at km_db_berkeley.c:827
#4  0x08a5cf7f in restore_db_subs () at subscribe.c:2475
#5  0x08a05193 in mod_init () at presence.c:344
#6  0x081bb23b in init_mod (m=0xb6f5c918) at sr_module.c:966
#7  0x081bafd0 in init_mod (m=0xb6f5cbe4) at sr_module.c:963
#8  0x081bb513 in init_modules () at sr_module.c:995
#9  0x080e4c77 in main (argc=3, argv=0xbf922c04) at main.c:2502
OR  (variant 2):
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x00eef343 in __db_prdbt () from /lib/libdb-4.8.so
#2  0x00d408d9 in km_bdblib_create_dbenv (_dbenv=0xb7050b7c, _home=0xbf9f2784 "/var/lib/berkeley_kamailio42.db") at km_bdb_lib.c:320
#3  0x00d41cd9 in km_bdblib_get_db (_s=0xbf9f2b7c) at km_bdb_lib.c:409
#4  0x00d56302 in bdb_init (_sqlurl=0x7aaeb10) at km_db_berkeley.c:213
#5  0x07a35528 in mod_init () at presence.c:312
#6  0x081bb23b in init_mod (m=0xb6ff4a8c) at sr_module.c:966
#7  0x081bafd0 in init_mod (m=0xb6ff4d58) at sr_module.c:963
#8  0x081bafd0 in init_mod (m=0xb6ff4f6c) at sr_module.c:963
#9  0x081bafd0 in init_mod (m=0xb6ff5118) at sr_module.c:963
#10 0x081bafd0 in init_mod (m=0xb6ff5314) at sr_module.c:963
#11 0x081bafd0 in init_mod (m=0xb6ff5550) at sr_module.c:963
#12 0x081bafd0 in init_mod (m=0xb6ff5848) at sr_module.c:963
#13 0x081bafd0 in init_mod (m=0xb6ff5b8c) at sr_module.c:963
#14 0x081bafd0 in init_mod (m=0xb6ff5dac) at sr_module.c:963
#15 0x081bafd0 in init_mod (m=0xb6ff5f9c) at sr_module.c:963
#16 0x081bafd0 in init_mod (m=0xb6ff62b0) at sr_module.c:963
#17 0x081bafd0 in init_mod (m=0xb6ff674c) at sr_module.c:963
#18 0x081bafd0 in init_mod (m=0xb6ff697c) at sr_module.c:963
#19 0x081bb513 in init_modules () at sr_module.c:995
#20 0x080e4c77 in main (argc=3, argv=0xbf9f37e4) at main.c:2502
 
However, it seems to be caused by the presence.c file of the presence module all time. When I comment out any presence related module and use the usrloc module (e.g.) only, it is working fine with berkeley DB, too. The configuration itself is working fine with DB_ENGINE MySQL instead of Berkeley. I´ve also tested different versions of Berkeley DB (4.7 (originally delivered with the OS), 4.8, 5.3 and 6.1). The result is always the same....
 
Could anybody take a look at this dump output? What is causing these dumps? Is there any bug within the presence modules? I cannot move to another DB so easy, as it should be used (in future) in embedded environment.....
 
Thanks in advance!
 
br
Klaus