Exception with ngx_event_timer_init() in win32

Maxim Dounin mdounin at mdounin.ru
Wed Jul 13 17:12:35 MSD 2011


Hello!

On Wed, Jul 13, 2011 at 04:19:52AM -0400, bigplum wrote:

> Hi, 
> 
> In win32 native api file: ngx_process_cycle.c init_process will call
> ngx_event_timer_init(), but the function ngx_mutex_init() does not
> implement for  win32 now, so ngx_event_timer_mutex will be set to 1.
> 
> And this function ngx_event_timer_init() will be called again in
> ngx_worker_thread(). The statement will access a invalid memory:
> 
>         ngx_event_timer_mutex->log = log;
>  
> Setting deamon and master_process to off in nginx.conf, this exception
> will be reproduced.
> 
> So why ngx_modules[n]->init_process called twice in
> ngx_single_process_cycle(), but ngx_worker_process_cycle called once
> only? 
> 
>     for (n = 0; ngx_modules[n]; n++) {
>         if (ngx_modules[n]->init_process) {
>             if (ngx_modules[n]->init_process(cycle) == NGX_ERROR) {
>                 /* fatal */
>                 exit(2);
>             }
>         }
>     }

Single process mode isn't something that is expected to work 
flawlesly.  Under unix it mostly works (except some problems with 
configuration reloading) and may be used for debugging.  Under 
windows it'll try to use threads and won't work at all as a 
result.

Fixing this particular problem won't help as there are plenty 
other thread-related problems.  Please also note it's listed in 
"possible future enchancements" list[1], and this future isn't 
here right now. :)

[1] http://nginx.org/en/docs/windows.html#possible_future_enhancements

Maxim Dounin



More information about the nginx mailing list