]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MAJOR: stats-file: ensure shm_stats_file_object struct mapping consistency
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 22 Oct 2025 14:04:23 +0000 (16:04 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 22 Oct 2025 18:52:22 +0000 (20:52 +0200)
commitd30b88a6cc47d662e92b524ad5818be312401d0e
tree469ec9a6bcd4173897f7c9d6f6d68f0a41b04637
parent4693ee0ff7a5fa4a12ff69b1a33adca142e781ac
BUG/MAJOR: stats-file: ensure shm_stats_file_object struct mapping consistency

As reported by @tianon on GH #3168, running haproxy on 32bits i386
platform would trigger the following BUG_ON() statement:

 FATAL: bug condition "sizeof(struct shm_stats_file_object) != 544" matched at src/stats-file.c:825
shm_stats_file_object struct size changed, is is part of the exported API: ensure all precautions were taken (ie: shm_stats_file version change) before adjusting this

In fact, some efforts were already taken to ensure shm_stats_file_object
struct size remains consistent on 64 vs 32 bits platforms, since
shm_stats_file_object is part of the public API and directly exposed in
the stats file.

However, some parts were overlooked: some structs that are embedded in
shm_stats_file_object struct itself weren't using fixed-width integers,
and would sometime be unaligned. The result of this is that it was
up to the compiler (platform-dependent) to choose how to deal with such
ambiguities, which could cause the struct mapping/size to be inconsistent
from one platform to another.

Hopefully this was caught by the BUG_ON() statement and with the precious
help of @tianon

To fix this, we now use fixed-width integers everywhere for members
(and submembers) of shm_stats_file_object struct, and we use explicit
padding where missing to avoid automatic padding when we don't expect
one. As for the previous commit, we leverage FIXED_SIZE() and
FIXED_SIZE_ARRAY() macro to set the expected width for each integer
without causing build issues on platform that don't support larger
integers.

No backport needed, this feature was introduced during 3.3-dev.
include/haproxy/counters-t.h