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!
This commit is contained in:
Willy Tarreau 2025-08-11 16:47:17 +02:00
parent e21bb531ca
commit 6be7b64bb4

View File

@ -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;