From 03926129b02fc62917850116f04a876bd0189e41 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 12 Jan 2023 17:09:34 +0100 Subject: [PATCH] BUG/MEDIUM: peers: make "show peers" more careful about partial initialization 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/peers.c b/src/peers.c index dd73fa2..e3eb049 100644 --- a/src/peers.c +++ b/src/peers.c @@ -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)); -- 1.7.10.4