Hello,
in a Java web application I'm using the APR dbm functionality via JNA
which translates between Java and any shared library, in my case apr
and aprutil.
In this application I want to write a dbm file, to use for HTTPD
authentication. Since I do not want to make any assumption on the
initialization state of apr I would like to repeatedly initialize and
terminate apr.
In the past this has worked quite well on win32 and Linux 32-bit. Now
the webapp is being migrated to a 64-bit Linux system. Now the old
code doesn't work anymore. I was able to reproduce the problem in a
small C program which is reproduced here:
#include <apr-1.0/apr.h>
#include <apr-1.0/apr_dbm.h>
#include <stdio.h>
int main()
{
for(int i = 0; i < 2; i++)
{
apr_initialize();
apr_pool_t* pool = NULL;
apr_pool_create_ex(&pool, NULL, NULL, NULL);
apr_dbm_t* dbm = NULL;
apr_dbm_open_ex(&dbm, "db", "users.db", APR_DBM_RWCREATE,
APR_OS_DEFAULT, pool);
apr_dbm_close(dbm);
apr_pool_destroy(pool);
apr_terminate();
}
return 0;
}
On a 64-bit Linux machine the code crashes with a seg fault during the
second call to apr_dbm_open_ex. Additional error info:
# Problematic frame:
# C [libpthread.so.0+0x93c4] pthread_mutex_lock+0x4
Related to the situation described above I have a couple of questions:
- Is this an intended and valid use of apr and especially
apr_initialize/apr_terminate?
- Might the seg fault be caused by a bug in apr?
Version info:
libapr: 1.3.8-1build1
libaprutil: 1.3.9+dfsg-3build1
uname -a: Linux www 2.6.32-22-server #36-Ubuntu SMP Thu Jun 3 20:38:33
UTC 2010 x86_64 GNU/Linux
Thanks and best regards,
Christian