]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: pools: fix default pool alignment
authorWilly Tarreau <w@1wt.eu>
Wed, 22 Oct 2025 07:01:54 +0000 (09:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 22 Oct 2025 07:06:20 +0000 (09:06 +0200)
The doc in commit 977feb5617 ("DOC: api: update the pools API with the
alignment and typed declarations") says that alignment of zero means
the type's alignment. And this is followed by the DECLARE_TYPED_POOL()
macro. Yet this is not what is done in create_pool_from_reg() which
only raises the alignment to a void* if lower, while it should start
from the type's. The effect is haproxy refusing to start on some 32-bit
platforms since that commit, displaying an error such as:

   "BUG in the code: at src/mux_h2.c:454, requested creation of pool
    'h2s' aligned to 4 while type requires alignment of 8! Please
    report to developers. Aborting."

Let's just apply the default type's alignment.

Thanks to @tianon for reporting this in GH issue #3168. No backport is
needed since aligned pools are 3.3-only.

src/pool.c

index 9d247eb582bf6bf0a300cd4077fd7a1a557550c3..5108a81e6f4e8a504c5a26e9e7a584cb18a541cb 100644 (file)
@@ -344,6 +344,10 @@ struct pool_head *create_pool_from_reg(const char *name, struct pool_registratio
        unsigned int best_diff;
        int thr __maybe_unused;
 
+       /* alignment of zero means type alignment */
+       if (!alignment)
+               alignment = reg->type_align;
+
        /* extend alignment if needed */
        if (alignment < sizeof(void*))
                alignment = sizeof(void*);