[PATCH v2] nptl: Check alignment of pthread structs

Wilco Dijkstra Wilco.Dijkstra@arm.com
Wed Nov 19 16:45:36 GMT 2025


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.

---

diff --git a/sysdeps/nptl/pthreadP.h b/sysdeps/nptl/pthreadP.h
index 3c9a14c3d6f8b3eb076be3495bb2222ff0dc2aad..f98cdf4769bcfe320117c6dcefb11a5a9ba0e7a6 100644
--- a/sysdeps/nptl/pthreadP.h
+++ b/sysdeps/nptl/pthreadP.h
@@ -714,9 +714,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)		\



More information about the Libc-alpha mailing list