From cd57ee7ffa454315d37ee30548eab5853e521db8 Mon Sep 17 00:00:00 2001 From: Valentine Krasnobaeva Date: Sat, 26 Oct 2024 23:02:38 +0200 Subject: [PATCH] BUG/MINOR: mworker: mworker_reexec: unset MODE_STARTING before free startup logs ring Flag MODE_STARTING should be unset for master just before freeing the startup logs ring, as it triggers the copy of process logs to this ring, see the code of print_message(). Moreover with this flag set, if startup logs ring pointer is NULL, any print_message() triggered just before the execvp in mworker_reexec() will call startup_logs_init(). So ring will be allocated again "discretely" and after execvp we will lost its address, as in step_init_1() we will call again startup_logs_init(). No need to backport this fix as it's related to the latest master-worker refactoring. --- src/haproxy.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/haproxy.c b/src/haproxy.c index 0b4bab472b..bef1c46ca4 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -749,8 +749,6 @@ static void mworker_reexec(int hardreload) mworker_proc_list_to_env(); /* put the children description in the env */ - startup_logs_free(startup_logs); - /* during the reload we must ensure that every FDs that can't be * reuse (ie those that are not referenced in the proc_list) * are closed or they will leak. */ @@ -832,6 +830,12 @@ static void mworker_reexec(int hardreload) for (i = 1; i < old_argc; i++) next_argv[next_argc++] = old_argv[i]; + /* need to withdraw MODE_STARTING from master, because we have to free + * the startup logs ring here, see more details in print_message() + */ + global.mode &= ~MODE_STARTING; + startup_logs_free(startup_logs); + signal(SIGPROF, SIG_IGN); execvp(next_argv[0], next_argv); ha_warning("Failed to reexecute the master process [%d]: %s\n", pid, strerror(errno));