From 4034c4c33685f75283508fdba40f4a62022ec398 Mon Sep 17 00:00:00 2001 From: Michal Jankowski Date: Tue, 12 May 2026 08:45:54 +0200 Subject: [PATCH 1/2] PS-10070 [8.4]: fix for Apple clang https://perconadev.atlassian.net/browse/PS-10070 rapidjson's TypeHelper has specializations for the fixed-width integer typedefs (uint64_t etc.) but not for size_t. On macOS / Apple clang + libc++, size_t is 'unsigned long' which has no TypeHelper specialization, so get_element() fails to compile. Read into a uint64_t and assign back on success; uint64_t is recognized on all platforms. --- components/keyrings/keyring_kmip/config/config.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/components/keyrings/keyring_kmip/config/config.cc b/components/keyrings/keyring_kmip/config/config.cc index 82d42574db3b..55ae7c01684d 100644 --- a/components/keyrings/keyring_kmip/config/config.cc +++ b/components/keyrings/keyring_kmip/config/config.cc @@ -20,6 +20,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include #include #define RAPIDJSON_HAS_STDSTRING 1 @@ -142,9 +144,15 @@ bool find_and_read_config_file(std::unique_ptr &config_pod) { // optional attribute } - if (config_reader->get_element(config_options[7], - config_pod_tmp.get()->max_objects)) { - // optional attribute + // rapidjson's TypeHelper has specializations for the fixed-width integer + // typedefs (uint64_t etc.) but not for size_t. On macOS / Apple clang + + // libc++, size_t is 'unsigned long' which has no TypeHelper specialization, + // so get_element() fails to compile. Read into a uint64_t and + // assign back on success; uint64_t is recognized on all platforms. + if (uint64_t max_objects_tmp = config_pod_tmp.get()->max_objects; + !config_reader->get_element(config_options[7], + max_objects_tmp)) { + config_pod_tmp.get()->max_objects = static_cast(max_objects_tmp); } if (config_reader->get_element(config_options[8], From 7fce944931a166cdf035ecd2a987332a1fcd7450 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Sat, 9 May 2026 09:47:36 +0200 Subject: [PATCH 2/2] PS-10083 [8.4]: Relax thread_group_t false-sharing assert for non-glibc The static_assert(sizeof(thread_group_t) == 512, ...) in sql/threadpool_unix.cc has existed since PS 8.0.12 and was hand-tuned against the Linux/glibc layout of the embedded mysql_mutex_t and PSI structures. PS-10083 ("Add more statistics for threadpool", merged 2026-03-11 between 9.6.0 and 9.7.0) inserted two LiveStats members into thread_group_t and adjusted the trailing 'char padding[]' from 328 to 248 to keep the Linux total at exactly 512. LiveStats itself is platform-neutral (5 PODs, 40 bytes), but mysql_mutex_t expands by ~128 bytes on macOS / Apple clang + libc++, so on that platform the struct lands at 640 bytes and breaks the build: sql/threadpool_unix.cc:155:1: error: static assertion failed due to requirement 'sizeof(thread_group_t) == 512' The false-sharing guarantee comes from alignas(128); what matters is that the struct occupies a whole number of 128-byte cache lines, not that it is exactly 512 bytes (640 is also a multiple of 128). Replace the equality check with 'sizeof % 128 == 0' so Linux/glibc, libc++ on macOS, and any future libstdc++ layout drift all pass while the no-false-sharing invariant remains enforced. --- sql/threadpool_unix.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc index 7532fdf283e0..c4a9419d8fce 100644 --- a/sql/threadpool_unix.cc +++ b/sql/threadpool_unix.cc @@ -152,8 +152,16 @@ struct alignas(128) thread_group_t { char padding[248]; }; -static_assert(sizeof(thread_group_t) == 512, - "sizeof(thread_group_t) must be 512 to avoid false sharing"); +// thread_group_t is alignas(128); to avoid false sharing the struct must +// occupy a whole number of 128-byte cache lines. Linux/glibc lays this +// out at exactly 512 bytes (the original size when 'padding[248]' was +// hand-tuned), but on macOS / libc++ pthread_mutex_t is larger so the +// struct grows past 512 (e.g. to 640). Both sizes are still multiples of +// 128 so the false-sharing guarantee holds; assert that invariant +// rather than the absolute size. +static_assert(sizeof(thread_group_t) % 128 == 0, + "sizeof(thread_group_t) must be a multiple of 128 to avoid " + "false sharing"); static thread_group_t all_groups[MAX_THREAD_GROUPS]; static uint group_count;