From 6be7b64bb459f759fcf0ff5dbc695c02aa7baf0e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 11 Aug 2025 16:47:17 +0200 Subject: [PATCH] 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! --- src/pool.c | 7 +++++++ 1 file changed, 7 insertions(+) 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;