From: Alessandro Astone Date: Thu, 19 Mar 2026 10:13:34 +0100 Subject: Bug 2024326 - Mutex,ConditionVariable: Ensure alignment of platformData r=jandem,glandium Declaring the variable as (void*)[] does not guarantee proper alignment to hold a pthread_mutex_t/pthread_cond_t. Since we're already including pthread.h, make the variable actually hold the wanted type. Here we keep using an array of size 1 to satisfy existing expectations that the name platformData_ is an array. Forwarded: https://phabricator.services.mozilla.com/D288470 Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=2024326 Bug-Ubuntu: https://launchpad.net/bugs/2144310 --- mozglue/misc/PlatformConditionVariable.h | 5 +---- mozglue/misc/PlatformMutex.h | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/mozglue/misc/PlatformConditionVariable.h b/mozglue/misc/PlatformConditionVariable.h index 61fb06a..70a14b8 100644 --- a/mozglue/misc/PlatformConditionVariable.h +++ b/mozglue/misc/PlatformConditionVariable.h @@ -55,10 +55,7 @@ class ConditionVariableImpl { PlatformData* platformData(); #if !defined(XP_WIN) && !defined(__wasi__) - void* platformData_[sizeof(pthread_cond_t) / sizeof(void*)]; - static_assert(sizeof(pthread_cond_t) / sizeof(void*) != 0 && - sizeof(pthread_cond_t) % sizeof(void*) == 0, - "pthread_cond_t must have pointer alignment"); + pthread_cond_t platformData_[1]; #else void* platformData_[4]; #endif diff --git a/mozglue/misc/PlatformMutex.h b/mozglue/misc/PlatformMutex.h index ac5459c..9066dec 100644 --- a/mozglue/misc/PlatformMutex.h +++ b/mozglue/misc/PlatformMutex.h @@ -49,10 +49,7 @@ class MutexImpl { PlatformData* platformData(); #if !defined(XP_WIN) && !defined(__wasi__) - void* platformData_[sizeof(pthread_mutex_t) / sizeof(void*)]; - static_assert(sizeof(pthread_mutex_t) / sizeof(void*) != 0 && - sizeof(pthread_mutex_t) % sizeof(void*) == 0, - "pthread_mutex_t must have pointer alignment"); + pthread_mutex_t platformData_[1]; #else void* platformData_[6]; #endif