Opened 6 years ago

Closed 6 years ago

#1632 closed defect (wontfix)

Pool cleanups are not called in the daemonization

Reported by: spacewanderlzx@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.15.x
Keywords: Cc:
uname -a: Linux machine_name 4.13.0-36-generic #40-Ubuntu SMP Fri Feb 16 20:07:48 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.13.6

Description

When we run our testsuites with LeakSanitizer, we noticed lots of leak reports.

After some investigations, we found that the pool cleanups registered with ngx_cycle->pool are not invoked when the parent exits during the daemonization, which causes the leak reports.

I am not sure whether it is a bug, or should we change the testsuite to run Nginx in "daemon off" mode.
Anyway, it could be 'fixed' via a simple change:

--- a/src/os/unix/ngx_daemon.c
+++ b/src/os/unix/ngx_daemon.c
@@ -23,6 +23,7 @@ ngx_daemon(ngx_log_t *log)
         break;
 
     default:
+        ngx_destroy_pool(ngx_cycle->pool);
         exit(0);
     }

Note that this change doesn't cover signaller mode and error handling path.

Change History (1)

comment:1 by Maxim Dounin, 6 years ago

Resolution: wontfix
Status: newclosed

The ngx_daemon() function is not expected to free ngx_cycle or any other global variables - all these variables will be available in the new process, and exit() will free anything in the old process. The best solution here would be to configure LeakSanitizer to ignore these "leaks" as clearly these are false positives.

Note: See TracTickets for help on using tickets.