From: Willy Tarreau Date: Mon, 2 Jan 2023 07:33:18 +0000 (+0100) Subject: BUG/MINOR: debug: don't mask the TH_FL_STUCK flag before dumping threads X-Git-Tag: v2.8-dev1~28 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=b5662519df8006e25e3259c2737fc87aa9e35e84;p=thirdparty%2Fhaproxy.git BUG/MINOR: debug: don't mask the TH_FL_STUCK flag before dumping threads Commit f0c86ddfe ("BUG/MEDIUM: debug: fix parallel thread dumps again") added a clearing of the TH_FL_STUCK flag before dumping threads in case of parallel dumps, but that was in part a sort of workaround for some remains of the commit that introduced the flag in 2.0 before the watchdog existed, and which would set it after dumping a thread: e6a02fa65 ("MINOR: threads: add a "stuck" flag to the thread_info struct"), and in part an attempt to avoid that a thread waiting for too long during the dump would get the flag set. But that is not possible, a thread waiting for being dumped has the harmless bit set and doesn't get the stuck bit. What happens in fact is that issuing "show threads" in fast loops ends up causing some threads to keep their STUCK bit that was set at the end of "show threads", and confuses the output. The problem with doing this is that the flag is cleared before the thread is dumped, and since this flag is used to decide whether to show a backtrace or not, we don't get backtraces anymore of stuck threads since the commit above in 2.7. This patch just removes the two points where the flag was cleared by the commit above. It should be backported to 2.7. --- diff --git a/src/debug.c b/src/debug.c index ba396306d3..c9b912e98c 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1561,9 +1561,6 @@ void debug_handler(int sig, siginfo_t *si, void *arg) while ((HA_ATOMIC_LOAD(&thread_dump_state) & THREAD_DUMP_TMASK) != tid) ha_thread_relax(); - /* make sure we don't count all that wait time against us */ - HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_STUCK); - if (!harmless) thread_harmless_end(); @@ -1610,9 +1607,6 @@ void debug_handler(int sig, siginfo_t *si, void *arg) while (HA_ATOMIC_LOAD(&thread_dump_state) & THREAD_DUMP_PMASK) ha_thread_relax(); - /* make sure we don't count all that wait time against us */ - HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_STUCK); - if (!harmless) thread_harmless_end();