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.
This commit is contained in:
David Chisnall
2019-07-05 09:16:08 +01:00
parent 829d8e856b
commit 896b248c8c

View File

@@ -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<size_t>(4096, align);
size_t log2align = bits::next_pow2_bits(align);