From: Wilco Dijkstra Date: Thu, 4 Dec 2025 15:17:25 +0000 (+0000) Subject: nptl: Check alignment of pthread structs X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=83dd79dffbcdd0ad57bf5471fbc1a3fd1d4e7e9a;p=thirdparty%2Fglibc.git nptl: Check alignment of pthread structs Report assertion failure if the alignment of external pthread structs is lower than the internal version. This triggers on type mismatches like in BZ #33632. Reviewed-by: Yury Khrustalev --- diff --git a/sysdeps/nptl/pthreadP.h b/sysdeps/nptl/pthreadP.h index c9b5a2af11..4f649267b3 100644 --- a/sysdeps/nptl/pthreadP.h +++ b/sysdeps/nptl/pthreadP.h @@ -698,9 +698,11 @@ check_stacksize_attr (size_t st) _Static_assert (sizeof (type) == size, \ "sizeof (" #type ") != " #size) -#define ASSERT_PTHREAD_INTERNAL_SIZE(type, internal) \ - _Static_assert (sizeof ((type) { { 0 } }).__size >= sizeof (internal),\ - "sizeof (" #type ".__size) < sizeof (" #internal ")") +#define ASSERT_PTHREAD_INTERNAL_SIZE(type, internal) \ + { _Static_assert (sizeof ((type) { { 0 } }).__size >= sizeof (internal), \ + "sizeof (" #type ".__size) < sizeof (" #internal ")"); \ + _Static_assert (_Alignof (type) >= _Alignof (internal), \ + "_Aignof (" #type ") < _Alignof (" #internal ")"); } #define ASSERT_PTHREAD_STRING(x) __STRING (x) #define ASSERT_PTHREAD_INTERNAL_OFFSET(type, member, offset) \