]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stats-file: reject tgid 0 when preloading shm objects
authorWilly Tarreau <w@1wt.eu>
Thu, 6 Aug 2026 07:25:13 +0000 (09:25 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Aug 2026 15:59:27 +0000 (17:59 +0200)
When preloading the shared memory stats file at startup,
shm_stats_file_preload() only checked that the tgid read from each
object was not greater than the number of configured thread groups,
but it forgot to also check for zero, which can correspond to an
entry in the process of being reused, and that would cause the
process to crash on startup.

Let's just also test 0. This should be backported to 3.3.

Reported-by: Claude (ANT-2026-71A0JC6Q)
src/stats-file.c

index 7988f3bb90304c513f1b5861fb6a240dcc0ef10d..761f0d2ccefe06740072c2420ba35fc49034aa5e 100644 (file)
@@ -766,8 +766,8 @@ static void shm_stats_file_preload(void)
 
                obj_tgid = HA_ATOMIC_LOAD(&curr_obj->tgid);
 
-               /* ignore object if greater than our max tgid */
-               if (obj_tgid <= global.nbtgroups &&
+               /* ignore object if tgid greater than our max tgid (or null) */
+               if (obj_tgid && obj_tgid <= global.nbtgroups &&
                    (node = guid_lookup(curr_obj->guid))) {
                        switch (*node->obj_type) {
                                case OBJ_TYPE_LISTENER: