https://bz.apache.org/bugzilla/show_bug.cgi?id=60189

            Bug ID: 60189
           Summary: httpd with worker/event mpm segfaults after multiple
                    successive graceful reloads
           Product: Apache httpd-2
           Version: 2.4.23
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: Core
          Assignee: [email protected]
          Reporter: [email protected]

Created attachment 34314
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34314&action=edit
Patch fixing the issue

Apache httpd in the latest version (2.4.23) configured with worker/event mpm
segfaults after receiving multiple successive graceful reloads (SIGHUP).


Reproducer:
  1. Install httpd
  2. Ensure using worker or event
     (e.g.: sed -i -e '/^Load/s/^/#/' -e '/#Load.*event/s/^#//'
/etc/httpd/conf.modules.d/00-mpm.conf)
  3. systemctl restart httpd
  4. systemctl start httpd; n=0; while :; do ((n++)); systemctl reload httpd ||
break; done 2>/dev/null; echo reload failed after count=$n


This causes that httpd segfaults after many consequent httpd's reloads. This
can be very unpleasant, if someone has multiple custom files in
/etc/logrotate.d/ with httpd reload inside it.


BT from the core:

(gdb) bt
#0  0x00007fb40864c900 in ?? ()
#1  <signal handler called>
#2  0x00007fb4144561a3 in __select_nocancel () at
../sysdeps/unix/syscall-template.S:84
#3  0x00007fb414b66975 in apr_sleep (t=t@entry=46875) at time/unix/time.c:246
#4  0x00007fb414b5a833 in free_proc_chain (procs=0x555d904709b8) at
memory/unix/apr_pools.c:2483
#5  0x00007fb414b5b7c3 in apr_pool_clear (pool=0x555d903b4188) at
memory/unix/apr_pools.c:777
#6  0x0000555d90044d5f in main (argc=<optimized out>, argv=<optimized out>) at
main.c:713

I'm proposing following change:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c
index c64b08f..5852685 100644
--- a/server/mpm/event/event.c
+++ b/server/mpm/event/event.c
@@ -2735,6 +2735,7 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t *
plog, server_rec * s)

     /* we've been told to restart */
     apr_signal(SIGHUP, SIG_IGN);
+    apr_signal(AP_SIG_GRACEFUL, SIG_IGN);

     if (one_process) {
         /* not worth thinking about */
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I think, AP_SIG_GRACEFUL should be ignored, after we announced to httpd, we are
going to restart, because otherwise, it can cause RACE when AP_SIG_GRACEFUL is
received and httpd is just in apr_pool_clear function. 

If you need any further info, feel free to ask.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to