git: 5835d34761a0 - stable/14 - libthr: properly align struct pthreads

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 02 May 2025 07:31:18 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=5835d34761a0b905a987986632222aa7de7fb083

commit 5835d34761a0b905a987986632222aa7de7fb083
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-04-24 21:24:19 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-05-02 07:30:51 +0000

    libthr: properly align struct pthreads
    
    PR:     285711
    
    (cherry picked from commit 22e564c74eb20e14bd93fd9fdde20e38a29cfcf1)
---
 lib/libthr/thread/thr_list.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/libthr/thread/thr_list.c b/lib/libthr/thread/thr_list.c
index 6b41951aaf59..2c41225fa6cb 100644
--- a/lib/libthr/thread/thr_list.c
+++ b/lib/libthr/thread/thr_list.c
@@ -151,11 +151,13 @@ _thr_alloc(struct pthread *curthread)
 		if (total_threads > MAX_THREADS)
 			return (NULL);
 		atomic_add_int(&total_threads, 1);
-		thread = __thr_calloc(1, sizeof(struct pthread));
+		thread = __thr_aligned_alloc_offset(_Alignof(struct pthread),
+		    sizeof(struct pthread), 0);
 		if (thread == NULL) {
 			atomic_add_int(&total_threads, -1);
 			return (NULL);
 		}
+		memset(thread, 0, sizeof(*thread));
 		if ((thread->sleepqueue = _sleepq_alloc()) == NULL ||
 		    (thread->wake_addr = _thr_alloc_wake_addr()) == NULL) {
 			thr_destroy(curthread, thread);