From: Willy Tarreau Date: Tue, 19 Jul 2022 13:58:00 +0000 (+0200) Subject: BUG/MEDIUM: fd/threads: fix incorrect thread selection in wakeup broadcast X-Git-Tag: v2.7-dev3~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1640f79f;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: fd/threads: fix incorrect thread selection in wakeup broadcast In commit cfdd20a0b ("MEDIUM: fd: support broadcasting updates for foreign groups in updt_fd_polling") we decided to pick a random thread number among a set of candidates for a wakeup in case we need an instant change. But the thread count range was wrong (MAX_THREADS) instead of tg->count, resulting in random crashes when thread groups are > 1 and MAX_THREADS > 64. No backport is needed, this was introduced in 2.7-dev2. --- diff --git a/src/fd.c b/src/fd.c index b4b3d7b48d..634a6a33b5 100644 --- a/src/fd.c +++ b/src/fd.c @@ -486,7 +486,7 @@ void updt_fd_polling(const int fd) fd_add_to_fd_list(&update_list[tgrp - 1], fd); - thr = one_among_mask(fdtab[fd].thread_mask & tg->threads_enabled, statistical_prng_range(MAX_THREADS)); + thr = one_among_mask(fdtab[fd].thread_mask & tg->threads_enabled, statistical_prng_range(tg->count)); thr += ha_tgroup_info[tgrp - 1].base; wake_thread(thr);