NetBSD Problem Report #60025

From www@netbsd.org  Sat Feb 21 17:18:17 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.netbsd.org", Issuer "R13" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 716651A923C
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 21 Feb 2026 17:18:17 +0000 (UTC)
Message-Id: <20260221171816.1B1F81A923D@mollari.NetBSD.org>
Date: Sat, 21 Feb 2026 17:18:16 +0000 (UTC)
From: hpaluch@seznam.cz
Reply-To: hpaluch@seznam.cz
To: gnats-bugs@NetBSD.org
Subject: 11.0_BETA+: glxinfo (or any Mesa app in swrast mode) crashes on exit with SIGSEGV
X-Send-Pr-Version: www-1.0
X-From4GNATS: "hpaluch@seznam.cz via gnats" <gnats-admin@NetBSD.org>

>Number:         60025
>Category:       xsrc
>Synopsis:       11.0_BETA+: glxinfo (or any Mesa app in swrast mode) crashes on exit with SIGSEGV
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    mrg
>State:          analyzed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 21 17:20:00 +0000 2026
>Closed-Date:    
>Last-Modified:  Wed Mar 04 20:20:02 +0000 2026
>Originator:     Henryk Paluch
>Release:        NetBSD 11.0_BETA  or later (also RC1 affected)
>Organization:
N/A
>Environment:
NetBSD nbsd-sgate350.example.com 11.0_BETA NetBSD 11.0_BETA (GENERIC)
>Description:
Please see complete Mailing list thread: https://marc.info/?l=netbsd-users&m=176604430720235&w=2

Problem: any program using new Mesa in "swrast" mode (no HW acceleration) from 
(xsrc/external/mit/MesaLib/dist/src/mesa/main/context.c r1.9), including NetBSD 11.0_BETA (or latest RC1) will crash on exit, because Mesa now calls atexit(3) from dlopen(3) DSO that is not supported in NetBSD. 

In base system this affects at least:

- glxinfo
- glxgears
>How-To-Repeat:
You need:
* NetBSD 11.0_BETA or later, including 11.0_RC1 (one that includes commit from: xsrc/external/mit/MesaLib/dist/src/mesa/main/context.c r1.9)
* X11 environment in "swrast" mode (without acceleration)

Run any application using Mesa,  for example glxinfo or glxgears. It will always crash on exit with SIGSEGV.

Example:
$ uname -a

NetBSD nbsd-sgate350.example.com 11.0_BETA NetBSD 11.0_BETA (GENERIC) 
#0: Sun Dec 14 14:19:17 UTC 2025  mkrepro@mkrepro.
NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

$ glxinfo

name of display: :0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
(lot of output)
0x388 32 tc  0  32  0 r  y .   8  8  8  8 .  s  0 32  0  0  0  0  0  0 0 
None

[1]   Segmentation fault (core dumped) glxinfo

$ gdb glxinfo glxinfo.core

Reading symbols from glxinfo...
Reading symbols from /usr/libdata/debug//usr/X11R7/bin/glxinfo.debug...
[New process 1979]
Core was generated by `glxinfo'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007b60f1d01eb3 in ?? ()
+bt
#0  0x00007b60f1d01eb3 in ?? ()
#1  0x00007b60f6b1795f in __cxa_finalize (dso=dso@entry=0x0) at 
/usr/src/lib/libc/stdlib/atexit.c:222
#2  0x00007b60f6b1753b in exit (status=0) at 
/usr/src/lib/libc/stdlib/exit.c:60
#3  0x0000000000b696d2 in ___start (cleanup=<optimized out>, 
ps_strings=0x7f7fff6dcfe0) at /usr/src/lib/csu/common/crt0-common.c:375
#4  0x00007f7ff77f08a8 in ?? () from /usr/libexec/ld.elf_so
#5  0x0000000000000001 in ?? ()
#6  0x00007f7fff6dc120 in ?? ()
#7  0x0000000000000000 in ?? ()
+q

Please note that stacktrace makes no sense at first sight. It was only found by RVP that it is, because atexit(3) handler registered in dlopen(3)ed library is called too late - long after dlclose(3) - at the moment when such library is no longer mapped to memory. That's is reason why such address has no symbols and casues SIGSEGV.
>Fix:
There was long discussion what is proper fix:
1. changing atexit(3) behavior to work properly when called with dlopen(3) so libraries (as done in Linux an other BSDs)
2.  replace atexit(3) in Mesa with supported dtor construct

Later option won and there was proposed patch by RVP that fixes this problem:
- from https://marc.info/?l=netbsd-users&m=176644672910756&w=2

```
diff -urN a/xsrc/external/mit/MesaLib/dist/src/mesa/main/context.c \
                b/xsrc/external/mit/MesaLib/dist/src/mesa/main/context.c
--- a/xsrc/external/mit/MesaLib/dist/src/mesa/main/context.c	2022-05-09 \
                01:27:38.000000000 +0000
+++ b/xsrc/external/mit/MesaLib/dist/src/mesa/main/context.c	2025-12-22 \
22:39:24.502696165 +0000 @@ -256,14 +256,11 @@
   * Calls all the various one-time-fini functions in Mesa
   */

-static GLbitfield api_init_mask = 0x0;
  static void __attribute__((__destructor__))
  one_time_fini(void)
  {
-   if (api_init_mask) {
-      glsl_type_singleton_decref();
-      _mesa_locale_fini();
-   }
+   glsl_type_singleton_decref();
+   _mesa_locale_fini();
  }

  /**
@@ -292,7 +289,9 @@
        _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
     }

+#if 0
     atexit(one_time_fini);
+#endif

  #if defined(DEBUG)
     if (MESA_VERBOSE != 0) {
```

RVPs patch was verified on following post: https://marc.info/?l=netbsd-users&m=176650588111131&w=2

My suggestion is to use RPV's solution so we can fix this problem (that affects everybody with any Mesa application with swrast driver) before final 11.0 RELEASE.

Again, please see whole mailing list thread for details: https://marc.info/?t=176604443000001&r=1&w=2

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->analyzed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Sat, 21 Feb 2026 21:25:13 +0000
State-Changed-Why:
This is yet another mesa atexit bug that is already patched in pkgsrc:
https://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/graphics/MesaLib/patches/patch-src_mesa_main_context.c?rev=1.6
Someone needs to systematically go through and ensure all of these
patches are synced to xsrc; it is embarrassing that we keep hitting the
same issues over and over again.


Responsible-Changed-From-To: xsrc-manager->mrg
Responsible-Changed-By: mrg@NetBSD.org
Responsible-Changed-When: Sun, 22 Feb 2026 03:00:51 +0000
Responsible-Changed-Why:
there are 9 patches in pkgsrc with the atexit changes.  i'll make ours
match what it has.. it includes reverting part of a local patch which
is also the first chunk in this PR's suggested change.


From: "matthew green" <mrg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60025 CVS commit: xsrc/external/mit/MesaLib/dist/src
Date: Sun, 22 Feb 2026 08:35:22 +0000

 Module Name:	xsrc
 Committed By:	mrg
 Date:		Sun Feb 22 08:35:21 UTC 2026

 Modified Files:
 	xsrc/external/mit/MesaLib/dist/src/drm-shim: drm_shim.c
 	xsrc/external/mit/MesaLib/dist/src/egl/main: eglglobals.c
 	xsrc/external/mit/MesaLib/dist/src/gallium/frontends/osmesa: osmesa.c
 	xsrc/external/mit/MesaLib/dist/src/glx: dri_common.c
 	xsrc/external/mit/MesaLib/dist/src/mesa/main: context.c extensions.c
 	    formats.c
 	xsrc/external/mit/MesaLib/dist/src/util: u_process.c u_queue.c

 Log Message:
 sync the atexit() / dtor fixes with pkgsrc.

 also depends upon a define in a src Makefile, coming next.

 this should fix PR#60025.

 XXX: pullup-*


 To generate a diff of this commit:
 cvs rdiff -u -r1.1.1.1 -r1.2 \
     xsrc/external/mit/MesaLib/dist/src/drm-shim/drm_shim.c
 cvs rdiff -u -r1.7 -r1.8 \
     xsrc/external/mit/MesaLib/dist/src/egl/main/eglglobals.c
 cvs rdiff -u -r1.1.1.1 -r1.2 \
     xsrc/external/mit/MesaLib/dist/src/gallium/frontends/osmesa/osmesa.c
 cvs rdiff -u -r1.5 -r1.6 xsrc/external/mit/MesaLib/dist/src/glx/dri_common.c
 cvs rdiff -u -r1.10 -r1.11 \
     xsrc/external/mit/MesaLib/dist/src/mesa/main/context.c
 cvs rdiff -u -r1.5 -r1.6 \
     xsrc/external/mit/MesaLib/dist/src/mesa/main/extensions.c
 cvs rdiff -u -r1.1.1.6 -r1.2 \
     xsrc/external/mit/MesaLib/dist/src/mesa/main/formats.c
 cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/MesaLib/dist/src/util/u_process.c
 cvs rdiff -u -r1.5 -r1.6 xsrc/external/mit/MesaLib/dist/src/util/u_queue.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "matthew green" <mrg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60025 CVS commit: src/external/mit/xorg/lib
Date: Sun, 22 Feb 2026 08:36:03 +0000

 Module Name:	src
 Committed By:	mrg
 Date:		Sun Feb 22 08:36:03 UTC 2026

 Modified Files:
 	src/external/mit/xorg/lib: libmesa.mk

 Log Message:
 define HAVE_NOATEXIT here, syncing with how pkgsrc MesaLib builds.

 second and final part to fix PR#60025.

 XXX: pullup-*


 To generate a diff of this commit:
 cvs rdiff -u -r1.15 -r1.16 src/external/mit/xorg/lib/libmesa.mk

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60025 CVS commit: [netbsd-11] xsrc/external/mit/MesaLib/dist/src
Date: Wed, 4 Mar 2026 20:15:07 +0000

 Module Name:	xsrc
 Committed By:	martin
 Date:		Wed Mar  4 20:15:07 UTC 2026

 Modified Files:
 	xsrc/external/mit/MesaLib/dist/src/drm-shim [netbsd-11]: drm_shim.c
 	xsrc/external/mit/MesaLib/dist/src/egl/main [netbsd-11]: eglglobals.c
 	xsrc/external/mit/MesaLib/dist/src/gallium/frontends/osmesa [netbsd-11]:
 	    osmesa.c
 	xsrc/external/mit/MesaLib/dist/src/glx [netbsd-11]: dri_common.c
 	xsrc/external/mit/MesaLib/dist/src/mesa/main [netbsd-11]: context.c
 	    extensions.c formats.c
 	xsrc/external/mit/MesaLib/dist/src/util [netbsd-11]: u_process.c
 	    u_queue.c

 Log Message:
 Pull up following revision(s) (requested by mrg in ticket #200):

 	xsrc/external/mit/MesaLib/dist/src/glx/dri_common.c: revision 1.6
 	xsrc/external/mit/MesaLib/dist/src/util/u_queue.c: revision 1.6
 	xsrc/external/mit/MesaLib/dist/src/mesa/main/extensions.c: revision 1.5
 	xsrc/external/mit/MesaLib/dist/src/mesa/main/extensions.c: revision 1.6
 	xsrc/external/mit/MesaLib/dist/src/gallium/frontends/osmesa/osmesa.c: revision 1.2
 	xsrc/external/mit/MesaLib/dist/src/drm-shim/drm_shim.c: revision 1.2
 	xsrc/external/mit/MesaLib/dist/src/mesa/main/formats.c: revision 1.2
 	xsrc/external/mit/MesaLib/dist/src/egl/main/eglglobals.c: revision 1.7
 	xsrc/external/mit/MesaLib/dist/src/mesa/main/context.c: revision 1.10
 	xsrc/external/mit/MesaLib/dist/src/egl/main/eglglobals.c: revision 1.8
 	xsrc/external/mit/MesaLib/dist/src/mesa/main/context.c: revision 1.11
 	xsrc/external/mit/MesaLib/dist/src/util/u_process.c: revision 1.5

 revert prior atexit/destructor fixes in preparation of syncing with pkgsrc.

 sync the atexit() / dtor fixes with pkgsrc.
 also depends upon a define in a src Makefile, coming next.
 this should fix PR#60025.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1.1.1 -r1.1.1.1.4.1 \
     xsrc/external/mit/MesaLib/dist/src/drm-shim/drm_shim.c
 cvs rdiff -u -r1.6 -r1.6.4.1 \
     xsrc/external/mit/MesaLib/dist/src/egl/main/eglglobals.c
 cvs rdiff -u -r1.1.1.1 -r1.1.1.1.4.1 \
     xsrc/external/mit/MesaLib/dist/src/gallium/frontends/osmesa/osmesa.c
 cvs rdiff -u -r1.5 -r1.5.4.1 \
     xsrc/external/mit/MesaLib/dist/src/glx/dri_common.c
 cvs rdiff -u -r1.9 -r1.9.4.1 \
     xsrc/external/mit/MesaLib/dist/src/mesa/main/context.c
 cvs rdiff -u -r1.4 -r1.4.4.1 \
     xsrc/external/mit/MesaLib/dist/src/mesa/main/extensions.c
 cvs rdiff -u -r1.1.1.6 -r1.1.1.6.4.1 \
     xsrc/external/mit/MesaLib/dist/src/mesa/main/formats.c
 cvs rdiff -u -r1.4 -r1.4.4.1 \
     xsrc/external/mit/MesaLib/dist/src/util/u_process.c
 cvs rdiff -u -r1.5 -r1.5.4.1 \
     xsrc/external/mit/MesaLib/dist/src/util/u_queue.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60025 CVS commit: [netbsd-11] src/external/mit/xorg/lib
Date: Wed, 4 Mar 2026 20:17:02 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Wed Mar  4 20:17:01 UTC 2026

 Modified Files:
 	src/external/mit/xorg/lib [netbsd-11]: libmesa.mk

 Log Message:
 Pull up following revision(s) (requested by mrg in ticket #200):

 	external/mit/xorg/lib/libmesa.mk: revision 1.16

 define HAVE_NOATEXIT here, syncing with how pkgsrc MesaLib builds.
 second and final part to fix PR#60025.


 To generate a diff of this commit:
 cvs rdiff -u -r1.15 -r1.15.4.1 src/external/mit/xorg/lib/libmesa.mk

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.