Hi,
when using the following code :
pthread_mutex_t *mymutex;
apr_proc_mutex_t *apmutex = NULL;
apr_os_proc_mutex_t osmutex = {0};
apr_proc_mutex_create(&apmutex, NULL, APR_LOCK_PROC_PTHREAD, p);
apr_os_proc_mutex_get(&osmutex, apmutex);
mymutex = osmutex.pthread_interproc;
apr_os_proc_mutex_get() derefences the NULL pointer.
The function is implemented like this :
APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
apr_proc_mutex_t *pmutex)
{
#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE ||
APR_HAS_FLOCK_SERIALIZE || APR_HAS_POSIXSEM_SERIALIZE
ospmutex->crossproc = pmutex->interproc->filedes;
#endif
#if APR_HAS_PROC_PTHREAD_SERIALIZE
ospmutex->pthread_interproc = pmutex->pthread_interproc;
#endif
return APR_SUCCESS;
}
The problem is that on my linux system, all these APR_HAS_*_SERIALIZE
are defined to 1, but when a APR_LOCK_PROC_PTHREAD mutex is created,
apr_proc_mutex_t->pthread_interproc only is initialized, and
apr_proc_mutex_t->interproc is NULL (hence the segfault).
Maybe the patch above could be applied :
Index: locks/unix/proc_mutex.c
===================================================================
--- locks/unix/proc_mutex.c (revision 1582271)
+++ locks/unix/proc_mutex.c (working copy)
@@ -1013,7 +1013,12 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(ap
apr_proc_mutex_t *pmutex)
{
#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE ||
APR_HAS_FLOCK_SERIALIZE || APR_HAS_POSIXSEM_SERIALIZE
- ospmutex->crossproc = pmutex->interproc->filedes;
+ if (pmutex->interproc) {
+ ospmutex->crossproc = pmutex->interproc->filedes;
+ }
+ else {
+ ospmutex->crossproc = -1;
+ }
#endif
#if APR_HAS_PROC_PTHREAD_SERIALIZE
ospmutex->pthread_interproc = pmutex->pthread_interproc;
[END]
Regards,
Yann.