head 1.1; access; symbols; locks; strict; comment @ * @; 1.1 date 2026.11.30.09.08.28; author wiz; state Exp; branches; next ; commitid uerpYkcG24mjRs5H; desc @@ 1.1 log @mesa: carry over atexit() patches from MesaLib, simplified Fixes coredumps on exit. Reported upstream, let's see what happens. XXX: there are a couple more atexit() locations remaining that might need patching as well. Bump PKGREVISION. @ text @$NetBSD$ avoid atexit in shared libraries. https://gitlab.freedesktop.org/mesa/mesa/-/work_items/17072 --- src/util/u_queue.c.orig 2026-11-30 08:51:48.025676612 +0000 +++ src/util/u_queue.c @@@@ -55,6 +55,7 @@@@ util_queue_kill_threads_locked(struct util_queue *queu * are using the static variables. */ +static int global_init_called = 0; static once_flag atexit_once_flag = ONCE_FLAG_INIT; static struct list_head queue_list = { .next = &queue_list, @@@@ -62,11 +63,14 @@@@ static mtx_t exit_mutex; }; static mtx_t exit_mutex; -static void +static void __attribute__((__destructor__)) atexit_handler(void) { struct util_queue *iter; + if (!global_init_called) + return; + mtx_lock(&exit_mutex); /* Wait for all queues to assert idle. */ LIST_FOR_EACH_ENTRY(iter, &queue_list, head) { @@@@ -83,7 +87,7 @@@@ global_init(void) global_init(void) { mtx_init(&exit_mutex, mtx_plain); - atexit(atexit_handler); + global_init_called = 1; } static void @