head 1.1; access; symbols; locks; strict; comment @ * @; 1.1 date 2026.11.30.09.08.27; 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/egl/main/eglglobals.c.orig 2026-11-30 08:46:28.293194180 +0000 +++ src/egl/main/eglglobals.c @@@@ -47,6 +47,8 @@@@ static simple_mtx_t _eglGlobalMutex = SIMPLE_MTX_INITI static simple_mtx_t _eglGlobalMutex = SIMPLE_MTX_INITIALIZER; +static EGLBoolean registered = EGL_FALSE; + struct _egl_global _eglGlobal = { .Mutex = &_eglGlobalMutex, .DisplayList = NULL, @@@@ -100,9 +102,12 @@@@ struct _egl_global _eglGlobal = { .debugTypesEnabled = _EGL_DEBUG_BIT_CRITICAL | _EGL_DEBUG_BIT_ERROR, }; -static void +static void __attribute__((__destructor__)) _eglAtExit(void) { + if (!registered) + return; + _eglFiniDisplay(); _eglFiniDevice(); /* always called last */ } @@@@ -110,12 +115,9 @@@@ _eglRegisterAtExit(void) void _eglRegisterAtExit(void) { - static EGLBoolean registered = EGL_FALSE; - simple_mtx_lock(_eglGlobal.Mutex); if (!registered) { - atexit(_eglAtExit); registered = EGL_TRUE; } @