On 06/14/2017 11:02 PM, Shelley Shostak wrote:
Aha.  The problem is that the new haproxy.cfg file has hosts that are
not in the stat file.  If there is no state file, the haproxy.cfg file
is perfectly valid.

I've attached a self-contained config file and state file that will
reproduce the seg fault.  Also the output of haproxy -c using those
files.  Drop them into /tmp/haproxy for them to work.

Hello Shelley,

Thank you a lot for these files.

In fact there are several servers in .cfg file which are not listed in the state file.

The first hole is here in .cfg file (I have removed useless parameters).

  server upload3124.lv7.box.net
  server upload3125.lv7.box.net
  server upload3127.lv7.box.net

upload3126 is missing.

As there is no hole in the state file, and because the state file parser try to match servers arriving from .cfg first by id, then by name, *upload3126* server states will be applied to upload3127 server (they have the same id), then upload3127 states will be applied again to updload3127.

As there is at least one inconsistency between these two servers parameters which are not verified I guess this will make haproxy crash.

In fact such server lines in state files which do not match the configuration must be ignored.

The patch attached fixes this issue.

Regards,

Fred.
>From 95ef7cd2e01614cbe68b62ff0b0dcec1edb5c4a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= <flecai...@haproxy.com>
Date: Thu, 15 Jun 2017 14:09:10 +0200
Subject: [PATCH] BUG/MAJOR: server: Segfault after parsing server state file.

This patch makes the server state file parser ignore servers wich are
not present in the configuration file.
---
 src/server.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/server.c b/src/server.c
index 74450a1..008bafa 100644
--- a/src/server.c
+++ b/src/server.c
@@ -3479,10 +3479,12 @@ void apply_server_state(void)
 			else if (diff & PR_FBM_MISMATCH_ID) {
 				Warning("In backend '%s' (id: '%d'): server ID mismatch: from server state file: '%s', from running config %d\n", bk->id, bk->uuid, params[2], srv->puid);
 				send_log(bk, LOG_NOTICE, "In backend '%s' (id: %d): server ID mismatch: from server state file: '%s', from running config %d\n", bk->id, bk->uuid, params[2], srv->puid);
+				continue;
 			}
 			else if (diff & PR_FBM_MISMATCH_NAME) {
 				Warning("In backend '%s' (id: %d): server name mismatch: from server state file: '%s', from running config '%s'\n", bk->id, bk->uuid, params[3], srv->id);
 				send_log(bk, LOG_NOTICE, "In backend '%s' (id: %d): server name mismatch: from server state file: '%s', from running config '%s'\n", bk->id, bk->uuid, params[3], srv->id);
+				continue;
 			}
 
 			/* now we can proceed with server's state update */
-- 
2.1.4

Reply via email to