Potential bug in ngx_event.c

Rian Hunter rian at alum.mit.edu
Fri Aug 23 18:00:41 UTC 2019


Hello,

While browsing the source I noticed something that seemed wrong, even 
though I haven't observed any buggy behavior or have reproduced this bug 
myself. In ngx_event.c there is a line:

     if (ngx_shmtx_create(&ngx_accept_mutex, (ngx_shmtx_sh_t *) shared,
                          cycle->lock_file.data)
         != NGX_OK)
     {
         return NGX_ERROR;
     }

ngx_shmtx_create() is passed &ngx_accept_mutex, but this must be a 
pointer to a shared memory region otherwise the sem_wait()/sem_post() 
calls in ngx_shmtx.c will not function correctly. &ngx_accept_mutex is a 
pointer to BSS, ngx_accept_mutex_ptr is a pointer to shared memory. Is 
this intentional?

Rian


More information about the nginx-devel mailing list