From: Willy Tarreau Date: Mon, 11 Aug 2025 14:47:17 +0000 (+0200) Subject: MINOR: pools: always check that requested alignment matches the type's X-Git-Tag: v3.3-dev7~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6be7b64bb459f759fcf0ff5dbc695c02aa7baf0e;p=thirdparty%2Fhaproxy.git MINOR: pools: always check that requested alignment matches the type's For pool registrations that are created from the type declaration, we now have the ability to verify that the requested alignment matches the type's one. Let's not miss this opportunity, as we've met bugs in the past that were caused by such mismatches. The principle is simple: if the type alignment is known, we check that the configured alignment is at least as large as that one otherwise we refuse to start (since the code may crash at any moment). Obviously it doesn't crash for now! --- diff --git a/src/pool.c b/src/pool.c index d7f68e69b..4151cdb22 100644 --- a/src/pool.c +++ b/src/pool.c @@ -352,6 +352,13 @@ struct pool_head *create_pool_from_reg(const char *name, struct pool_registratio alignment++; } + if (reg->type_align && alignment < reg->type_align) { + ha_alert("BUG in the code: at %s:%u, requested creation of pool '%s' aligned to %u " + "while type requires alignment of %u! Please report to developers. Aborting.\n", + reg->file, reg->line, name, alignment, reg->type_align); + return NULL; + } + extra_mark = (pool_debugging & POOL_DBG_TAG) ? POOL_EXTRA_MARK : 0; extra_caller = (pool_debugging & POOL_DBG_CALLER) ? POOL_EXTRA_CALLER : 0; extra = extra_mark + extra_caller;