From 9ec0260698a2aab784204bbcb13f0f00987277c9 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 24 Oct 2024 15:04:25 +0200 Subject: [PATCH] BUILD: debug: silence a build warning with threads disabled Commit 091de0f9b2 ("MINOR: debug: slightly change the thread_dump_pointer signification") caused the following warning to be emitted when threads are disabled: src/debug.c: In function 'ha_thread_dump_one': src/debug.c:359:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] Let's just disguise the pointer to silence it. It should be backported where the patch above was backported, since it was part of a series aiming at making thread dumps more exploitable from core dumps. (cherry picked from commit f163cbfb7f893a06d158880a753cad01908143d8) [wt: s/MT_LIST_FOR_EACH_ENTRY_LOCKED/mt_list_for_each_entry_safe/ with two backup elements in 3.0] Signed-off-by: Willy Tarreau --- src/cfgparse.c | 4 ++-- src/debug.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cfgparse.c b/src/cfgparse.c index a40d36bdc..4e36960ac 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2708,7 +2708,7 @@ int check_config_validity() struct proxy *init_proxies_list = NULL; struct stktable *t; struct server *newsrv = NULL; - struct mt_list back; + struct mt_list *back1, back2; int err_code = 0; unsigned int next_pxid = 1; struct bind_conf *bind_conf; @@ -4130,7 +4130,7 @@ out_uri_auth_compat: /* we must finish to initialize certain things on the servers */ - MT_LIST_FOR_EACH_ENTRY_LOCKED(newsrv, &servers_list, global_list, back) { + mt_list_for_each_entry_safe(newsrv, &servers_list, global_list, back1, back2) { /* initialize idle conns lists */ if (srv_init_per_thr(newsrv) == -1) { ha_alert("parsing [%s:%d] : failed to allocate per-thread lists for server '%s'.\n", diff --git a/src/debug.c b/src/debug.c index a8359e7ff..e79291d3b 100644 --- a/src/debug.c +++ b/src/debug.c @@ -327,7 +327,7 @@ void ha_thread_dump_one(int thr, int from_signal) } leave: /* end of dump, setting the buffer to 0x1 will tell the caller we're done */ - HA_ATOMIC_OR((ulong*)&ha_thread_ctx[thr].thread_dump_buffer, 0x1UL); + HA_ATOMIC_OR((ulong*)DISGUISE(&ha_thread_ctx[thr].thread_dump_buffer), 0x1UL); } /* Triggers a thread dump from thread , either directly if it's the