From: Willy Tarreau Date: Fri, 15 Jul 2022 10:08:40 +0000 (+0200) Subject: BUG/MEDIUM: cli/threads: make "show threads" more robust on applets X-Git-Tag: v2.7-dev2~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=52f238d32601b513ef4716c55c01b5dd0afc548a;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: cli/threads: make "show threads" more robust on applets Running several concurrent "show threads" in loops might occasionally cause a segfault when trying to retrieve the stream from appctx_sc() which may be null while the applet is finishing. It's not easy to reproduce, it requires 3-5 sessions in parallel for about a minute or so. The appctx_sc must be checked before passing it to sc_strm(). This must be backported to 2.6 which also has the bug. --- diff --git a/src/debug.c b/src/debug.c index b793e3ec03..74249ff513 100644 --- a/src/debug.c +++ b/src/debug.c @@ -226,6 +226,7 @@ void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx) const struct stream *s = NULL; const struct appctx __maybe_unused *appctx = NULL; struct hlua __maybe_unused *hlua = NULL; + const struct stconn *sc; if (!task) { chunk_appendf(buf, "0\n"); @@ -256,8 +257,8 @@ void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx) if (task->process == process_stream && task->context) s = (struct stream *)task->context; - else if (task->process == task_run_applet && task->context) - s = sc_strm(appctx_sc((struct appctx *)task->context)); + else if (task->process == task_run_applet && task->context && (sc = appctx_sc((struct appctx *)task->context))) + s = sc_strm(sc); else if (task->process == sc_conn_io_cb && task->context) s = sc_strm(((struct stconn *)task->context));