Skip to content

Commit 22e564c

Browse files
committed
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 <[email protected]> Sponsored by: The FreeBSD Foundation MFC after: 1 week
1 parent 846229d commit 22e564c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/libthr/thread/thr_list.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,13 @@ _thr_alloc(struct pthread *curthread)
150150
if (total_threads > MAX_THREADS)
151151
return (NULL);
152152
atomic_add_int(&total_threads, 1);
153-
thread = __thr_calloc(1, sizeof(struct pthread));
153+
thread = __thr_aligned_alloc_offset(_Alignof(struct pthread),
154+
sizeof(struct pthread), 0);
154155
if (thread == NULL) {
155156
atomic_add_int(&total_threads, -1);
156157
return (NULL);
157158
}
159+
memset(thread, 0, sizeof(*thread));
158160
if ((thread->sleepqueue = _sleepq_alloc()) == NULL ||
159161
(thread->wake_addr = _thr_alloc_wake_addr()) == NULL) {
160162
thr_destroy(curthread, thread);

0 commit comments

Comments
 (0)