]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: cli/threads: make "show threads" more robust on applets
authorWilly Tarreau <w@1wt.eu>
Fri, 15 Jul 2022 10:08:40 +0000 (12:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Jul 2022 17:41:26 +0000 (19:41 +0200)
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.

src/debug.c

index b793e3ec03132c6486c0ddf8b6051869ab737816..74249ff51323235a9143ea571b6a0a8548835784 100644 (file)
@@ -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));