From 896b248c8ccea44ba52a99e2f18b6886a1a9c8d4 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Fri, 5 Jul 2019 09:16:08 +0100 Subject: [PATCH] Fix undefined behaviour in FreeBSD PAL. We were passing an argument less than 4K to the MAP_ALIGNED macro, which caused an undefined shift. The compiler helpfully propagated the undef values back to earlier in the code and gave us some exciting nonsense. --- src/pal/pal_freebsd.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pal/pal_freebsd.h b/src/pal/pal_freebsd.h index 9f3725b..8487f19 100644 --- a/src/pal/pal_freebsd.h +++ b/src/pal/pal_freebsd.h @@ -77,10 +77,7 @@ namespace snmalloc // Alignment must be a power of 2. assert(align == bits::next_pow2(align)); - if (align == 0) - { - align = 1; - } + align = bits::max(4096, align); size_t log2align = bits::next_pow2_bits(align);