Re: 11RC5: any EGL app (X11) crashes on exit with SIGSEGV - dlopen/atexit strikes again
Henryk Paluch <[email protected]> Sun, 5 Jul 2026 12:53:49 +0200
| Newsgroups | gmane.os.netbsd.general |
|---|---|
| Message-ID | <[email protected]> |
Hello!
I was able to fix SIGSEGV in libEGL with this patch:
--- usr/src/external/mit/xorg/lib/libEGL/Makefile.orig 2026-07-05
06:29:08.032120003 +0000
+++ usr/src/external/mit/xorg/lib/libEGL/Makefile 2026-07-05
06:31:34.364661709 +0000
@@ -92,7 +92,8 @@
-DHAVE_TIMESPEC_GET \
-DHAVE_PTHREAD \
-DHAVE_LIBDRM \
- -DHAVE_MINCORE
+ -DHAVE_MINCORE \
+ -DHAVE_NOATEXIT
.include "../libloader.mk"
Tested with following commands
cd /usr/src/
time ./build.sh -O ~/obj -T ~/tools -j 1C -x -U distribution
fastfetch # crashes with SIGSEGV
LD_LIBRARY_PATH=$HOME/obj/destdir.amd64/usr/X11R7/lib fastfetch # works
This resolution fully matches my expectation (that source file
eglglobals.c. is correct but macro HAVE_NOATEXIT is not defined at build
time).
Best regards
--Henryk Paluch
On 7/4/26 10:06 PM, Henryk Paluch wrote:
> Hello!
>
> Had found that specific X11 applications (fastfetch from latest pkgsrc)
> crashes on exit with SIGSEGV. It is same class of problem as reported
> earlier with Mesa applications - see https://gnats.netbsd.org/cgi-bin/
> query-pr-single.pl?number=60025 but this time it is in different place.
>
> How to reproduce:
> * have NetBSD 11.0_RC5 installed with X11
> * run application that uses libEGL - tested "fastfetch" from pkgsrc
> * it will SIGSEGV on exit - because of atexit(3) call inside libEGL.so
> library loaded via dlopen(3) - which is not supported on NetBSD.
>
>
> Details in GDB session:
> gdb /usr/pkg/bin/fastfetch.
>
> +break main
> Breakpoint 1 at 0x2bf57: file /home/ansible/pkgsrc/sysutils/fastfetch/
> work/fastfetch-2.64.2/src/fastfetch.c, line 831.
> +run
> Starting program: /usr/pkg/bin/fastfetch
>
> Breakpoint 1, main (argc=1, argv=0x7f7fff6f39f8) at /home/ansible/
> pkgsrc/sysutils/fastfetch/work/fastfetch-2.64.2/src/fastfetch.c:831
> 831 int main(int argc, char** argv) {
> +break dlopen
> Breakpoint 2 at 0x7adb3ee1b2f0: dlopen. (2 locations)
> +c
> Continuing.
>
> Breakpoint 2.2, dlopen (name=name@entry=0x7f7fff6f2b70
> "nss_compat.so.0", mode=mode@entry=513) at /usr/src/libexec/ld.elf_so/
> rtld.c:1090
> 1090 {
> +break atexit
> Breakpoint 3 at 0x7adb3ef1164b: file /usr/src/lib/libc/stdlib/atexit.c,
> line 265.
> +c
> Continuing.
>
> Breakpoint 2.2, dlopen (name=name@entry=0x7f7fff6f2b70 "nss_nis.so.0",
> mode=mode@entry=513) at /usr/src/libexec/ld.elf_so/rtld.c:1090
> 1090 {
> +c
> Continuing.
>
> Breakpoint 2.2, dlopen (name=name@entry=0x7f7fff6f2b70 "nss_files.so.0",
> mode=mode@entry=513) at /usr/src/libexec/ld.elf_so/rtld.c:1090
> 1090 {
> +c
> Continuing.
>
> Breakpoint 2.2, dlopen (name=name@entry=0x7f7fff6f2b70 "nss_dns.so.0",
> mode=mode@entry=513) at /usr/src/libexec/ld.elf_so/rtld.c:1090
> 1090 {
> +c
> Continuing.
>
> Breakpoint 3, atexit (func=0xe76dda <ffDestroyInstance>) at /usr/src/
> lib/libc/stdlib/atexit.c:265
> 265 return (__cxa_atexit_internal((void (*)(void *))func, NULL,
> NULL));
> +bt
> #0 atexit (func=0xe76dda <ffDestroyInstance>) at /usr/src/lib/libc/
> stdlib/atexit.c:265
> #1 0x0000000000e6df7b in main (argc=1, argv=0x7f7fff6f39f8) at /home/
> ansible/pkgsrc/sysutils/fastfetch/work/fastfetch-2.64.2/src/fastfetch.c:833
> +c
> Continuing.
>
> Breakpoint 2.2, dlopen (name=0x11b02d5 "libxcb-randr.so", mode=1) at /
> usr/src/libexec/ld.elf_so/rtld.c:1090
> 1090 {
> +c
> Continuing.
>
> Breakpoint 2.2, dlopen (name=0x11b0f6b "libXrandr.so", mode=1) at /usr/
> src/libexec/ld.elf_so/rtld.c:1090
> 1090 {
> +c
> Continuing.
>
> Breakpoint 2.2, dlopen (name=0x11af6b4 "libdrm.so", mode=1) at /usr/src/
> libexec/ld.elf_so/rtld.c:1090
> 1090 {
> +c
> Continuing.
>
> Breakpoint 2.2, dlopen (name=0x114afd1 "libEGL.so", mode=1) at /usr/src/
> libexec/ld.elf_so/rtld.c:1090
> 1090 {
> +c
> Continuing.
>
> Breakpoint 3, atexit (func=func@entry=0x7adb3ea9be60 <_eglAtExit>) at /
> usr/src/lib/libc/stdlib/atexit.c:265
> 265 return (__cxa_atexit_internal((void (*)(void *))func, NULL,
> NULL));
>
> +bt
> #0 atexit (func=func@entry=0x7adb3ea9be60 <_eglAtExit>) at /usr/src/
> lib/libc/stdlib/atexit.c:265
> #1 0x00007adb3ea9bf33 in _eglAddAtExitCall
> (func=func@entry=0x7adb3eaa9f7c <_eglFiniTSD>) at /usr/xsrc/external/
> mit/MesaLib/dist/src/egl/main/eglglobals.c:142
> #2 0x00007adb3eaaa05a in _eglInitTSD () at /usr/xsrc/external/mit/
> MesaLib/dist/src/egl/main/eglcurrent.c:94
> #3 _eglCheckedGetTSD () at /usr/xsrc/external/mit/MesaLib/dist/src/egl/
> main/eglcurrent.c:151
> #4 _eglGetCurrentThread () at /usr/xsrc/external/mit/MesaLib/dist/src/
> egl/main/eglcurrent.c:170
> #5 0x00007adb3ea9d7cb in _eglSetFuncName (object=0x0, objectType=12344,
> disp=0x0, funcName=0x7adb3eab0f70 <__func__.42> "eglGetProcAddress")
> at /usr/xsrc/external/mit/MesaLib/dist/src/egl/main/eglapi.c:270
> #6 eglGetProcAddress (procname=0x114af30 "glGetString") at /usr/xsrc/
> external/mit/MesaLib/dist/src/egl/main/eglapi.c:2732
> #7 0x0000000000e93ff1 in eglHandleData (result=0x7f7fff6f3130,
> data=0x7f7fff6f3030) at /home/ansible/pkgsrc/sysutils/fastfetch/work/
> fastfetch-2.64.2/src/detection/opengl/opengl_shared.c:137
> #8 0x0000000000e943f8 in ffOpenGLDetectByEGL (result=0x7f7fff6f3130)
> at /home/ansible/pkgsrc/sysutils/fastfetch/work/fastfetch-2.64.2/src/
> detection/opengl/opengl_shared.c:206
> #9 0x0000000001069c9b in ffDetectOpenGL (options=0x7f7fff6f3180,
> result=0x7f7fff6f3130) at /home/ansible/pkgsrc/sysutils/fastfetch/work/
> fastfetch-2.64.2/src/detection/opengl/opengl_linux.c:183
> #10 0x0000000000e9151c in detectByOpenGL (gpus=0x7f7fff6f3290) at /home/
> ansible/pkgsrc/sysutils/fastfetch/work/fastfetch-2.64.2/src/detection/
> gpu/gpu.c:92
> #11 0x0000000000e919cd in ffDetectGPU (options=0x7f7fff6f35e0,
> result=0x7f7fff6f3290) at /home/ansible/pkgsrc/sysutils/fastfetch/work/
> fastfetch-2.64.2/src/detection/gpu/gpu.c:197
> #12 0x0000000000f12119 in ffPrintGPU (options=0x7f7fff6f35e0) at /home/
> ansible/pkgsrc/sysutils/fastfetch/work/fastfetch-2.64.2/src/modules/gpu/
> gpu.c:169
> #13 0x0000000000e71a80 in parseStructureCommand (data=0x7f7fff6f3950,
> line=0x7adb3ed4527d "GPU", fn=0xe70be3 <genJsonResult>) at /home/
> ansible/pkgsrc/sysutils/fastfetch/work/fastfetch-2.64.2/src/common/impl/
> commandoption.c:183
> #14 0x0000000000e72969 in ffPrintCommandOption (data=0x7f7fff6f3950)
> at /home/ansible/pkgsrc/sysutils/fastfetch/work/fastfetch-2.64.2/src/
> common/impl/commandoption.c:218
> #15 0x0000000000e6d5c1 in run (data=0x7f7fff6f3950) at /home/ansible/
> pkgsrc/sysutils/fastfetch/work/fastfetch-2.64.2/src/fastfetch.c:764
> #16 0x0000000000e6e08b in main (argc=1, argv=0x7f7fff6f39f8) at /home/
> ansible/pkgsrc/sysutils/fastfetch/work/fastfetch-2.64.2/src/fastfetch.c:854
>
> +frame 1
> #1 0x00007adb3ea9bf33 in _eglAddAtExitCall
> (func=func@entry=0x7adb3eaa9f7c <_eglFiniTSD>) at /usr/xsrc/external/
> mit/MesaLib/dist/src/egl/main/eglglobals.c:142
> 142 atexit(_eglAtExit);
>
> +l
> 137
> 138 #if defined(HAVE_NOATEXIT)
> 139 registered = EGL_TRUE;
> 140 #else
> 141 if (!registered) {
> 142 atexit(_eglAtExit);
> 143 registered = EGL_TRUE;
> 144 }
> 145 #endif
> 146
>
>
> To me it looks like error that macro HAVE_NOATEXIT is not actually
> defined (but should be) - so atexit(3) is called accidentally.
>
> References:
> * https://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/MesaLib/dist/
> src/egl/main/eglglobals.c.diff?r1=1.7;r2=1.8;f=h
> * https://marc.info/?t=176604443000001&r=1&w=2
> * https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=60025
>
> Best regards
> --Henryk Paluch