BUILD: debug: silence a build warning with threads disabled
authorWilly Tarreau <w@1wt.eu>
Thu, 24 Oct 2024 13:04:25 +0000 (15:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Oct 2024 14:54:28 +0000 (16:54 +0200)
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 <w@1wt.eu>

src/cfgparse.c
src/debug.c

index a40d36b..4e36960 100644 (file)
@@ -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",
index a8359e7..e79291d 100644 (file)
@@ -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 <thr>, either directly if it's the