> On 28 Feb 2024, at 05:21, Piotr Sikora via nginx-devel > <nginx-devel@nginx.org> wrote: > > # HG changeset patch > # User Piotr Sikora <pi...@aviatrix.com> > # Date 1708977616 0 > # Mon Feb 26 20:00:16 2024 +0000 > # Branch patch002 > # Node ID f8d9fb94eab212f6e640b7a68ed111562e3157d5 > # Parent a8a592b9b62eff7bca03e8b46669f59d2da689ed > Core: free connections and read/write events at shutdown. > > Found with LeakSanitizer. > > Signed-off-by: Piotr Sikora <pi...@aviatrix.com> > > diff -r a8a592b9b62e -r f8d9fb94eab2 src/os/unix/ngx_process_cycle.c > --- a/src/os/unix/ngx_process_cycle.c Mon Feb 26 20:00:11 2024 +0000 > +++ b/src/os/unix/ngx_process_cycle.c Mon Feb 26 20:00:16 2024 +0000 > @@ -940,6 +940,7 @@ > ngx_worker_process_exit(ngx_cycle_t *cycle) > { > ngx_uint_t i; > + ngx_event_t *rev, *wev; > ngx_connection_t *c; > > for (i = 0; cycle->modules[i]; i++) { > @@ -989,8 +990,16 @@ > ngx_exit_cycle.files_n = ngx_cycle->files_n; > ngx_cycle = &ngx_exit_cycle; > > + c = cycle->connections; > + rev = cycle->read_events; > + wev = cycle->write_events; > + > ngx_destroy_pool(cycle->pool); > > + ngx_free(c); > + ngx_free(rev); > + ngx_free(wev); > + > ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, "exit"); > > exit(0);
Hello. Since this is not a real memory leak (the allocations made in the init_process method of the ngx_event_core_module module are used up to this function and already freed on exit automatically, as this function never returns), I don't think there is something to fix. (Further, the patch misses cycle->files for NGX_USE_FD_EVENT event methods. Also, it's probably better to free the memory in the exit_process method to obey the ownership (this would also fix missing ngx_free() calls on win32), but this would require moving code that uses these connections afterwards to catch socket leaks.) -- Sergey Kandaurov _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org https://mailman.nginx.org/mailman/listinfo/nginx-devel