On Thu, Mar 27, 2014 at 8:15 AM, Yann Ylavic <ylavic.dev@gmail.com> wrote:
> 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 :
>
trunk r1587063
1.5.x r1587064
Additionally I left this note as a 2.0 showstopper:
http://svn.apache.org/viewvc?view=revision&revision=1587066
Thanks!
> 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.
>
--
Born in Roswell... married an alien...
http://emptyhammock.com/
http://edjective.org/
|