diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2025-04-24 21:24:19 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2025-04-25 11:48:12 +0000 |
| commit | 22e564c74eb20e14bd93fd9fdde20e38a29cfcf1 (patch) | |
| tree | c229a8fd0052c127e7dfd1d968d970195fe5e557 | |
| parent | 846229d60b4fd6def666ce32cfc475ed96aabaf3 (diff) | |
libthr: properly align struct pthreads
For instance, the structure contains the struct _Unwind_Exception, and
it seems that libgcc requires specific alignment for it.
PR: 285711
Tested by: Oleg Sidorkin <osidorkin@gmail.com>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
| -rw-r--r-- | lib/libthr/thread/thr_list.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libthr/thread/thr_list.c b/lib/libthr/thread/thr_list.c index bbc1d2899cb9..5578abdc8727 100644 --- a/lib/libthr/thread/thr_list.c +++ b/lib/libthr/thread/thr_list.c @@ -150,11 +150,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); |
