From d4d92184b332628f35413f92918da09d4378a52c Mon Sep 17 00:00:00 2001 From: MacDue Date: Thu, 15 Jun 2023 22:56:05 +0100 Subject: [PATCH] AK: Align Function storage to __BIGGEST_ALIGNMENT__ outside kernel The previous alignment would always resolve to 8-bytes, which is below the required alignments of types that could exist in userspace (long double, 128-bit integers, SSE, etc). --- AK/Function.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AK/Function.h b/AK/Function.h index 76777e416b..b6d28bf436 100644 --- a/AK/Function.h +++ b/AK/Function.h @@ -276,11 +276,13 @@ private: #ifndef KERNEL // Empirically determined to fit most lambdas and functions. static constexpr size_t inline_capacity = 4 * sizeof(void*); + alignas(__BIGGEST_ALIGNMENT__) u8 m_storage[inline_capacity]; #else // FIXME: Try to decrease this. static constexpr size_t inline_capacity = 6 * sizeof(void*); + // In the Kernel nothing has an alignment > alignof(void*). + alignas(alignof(void*)) u8 m_storage[inline_capacity]; #endif - alignas(max(alignof(CallableWrapperBase), alignof(CallableWrapperBase*))) u8 m_storage[inline_capacity]; }; }