]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Check alignment of pthread structs
authorWilco Dijkstra <wilco.dijkstra@arm.com>
Thu, 4 Dec 2025 15:17:25 +0000 (15:17 +0000)
committerWilco Dijkstra <wilco.dijkstra@arm.com>
Thu, 4 Dec 2025 15:45:15 +0000 (15:45 +0000)
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 <yury.khrustalev@arm.com>
sysdeps/nptl/pthreadP.h

index c9b5a2af118ae1f3423e17f7391c717eba77db83..4f649267b3bb316374cb8f834e52f4556d9437b9 100644 (file)
@@ -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)           \