]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: peers: make "show peers" more careful about partial initialization
authorWilly Tarreau <w@1wt.eu>
Thu, 12 Jan 2023 16:09:34 +0000 (17:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 12 Jan 2023 16:09:34 +0000 (17:09 +0100)
Since 2.6 with commit 34e4085f8 ("MEDIUM: peers: Balance applets across
threads") the initialization of a peers appctx may be postponed with a
wakeup, causing some partially initialized appctx to be visible. The
"show peers" command used to only care about peers without appctx, but
now it must also take care of those with no stconn, otherwise it can
occasionally crash while dumping them.

This fix must be backported to 2.6. Thanks to Patrick Hemmer for
reporting the problem.

src/peers.c

index dd73fa25676da3e7e9c9d0bd98bcc53f3a05f34d..e3eb049a8791ba4bd1bd1b45f4b10efb6a3c52ad 100644 (file)
@@ -3898,6 +3898,14 @@ static int peers_dump_peer(struct buffer *msg, struct appctx *appctx, struct pee
                      peer->appctx->t ? peer->appctx->t->calls : 0);
 
        peer_cs = appctx_sc(peer->appctx);
+       if (!peer_cs) {
+               /* the appctx might exist but not yet be initialized due to
+                * deferred initialization used to balance applets across
+                * threads.
+                */
+               goto table_info;
+       }
+
        peer_s = __sc_strm(peer_cs);
 
        chunk_appendf(&trash, " state=%s", sc_state_str(sc_opposite(peer_cs)->state));