tech-x11 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: 9.1 xdpyinfo oddity



Just FYI,

Per analysis by rin@, ryo@, and soda@, this problem was
caused by XF86cleanup() in libXxf86dga invoked via atexit(3)
(or __attribute__((__destructor__)) in NetBSD xsrc):

http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/libXxf86dga/dist/src/XF86DGA.c.diff?r1=1.1&r2=1.2
---
diff -u -p -d -w -r1.1 -r1.2
--- external/mit/libXxf86dga/dist/src/XF86DGA.c	30 Jul 2008 02:57:51 -0000	1.1
+++ external/mit/libXxf86dga/dist/src/XF86DGA.c	4 Jan 2019 18:59:45 -0000	1.2
@@ -651,6 +647,9 @@ XF86DGADirectVideo(
 
 
 static void
+#ifdef __NetBSD__
+__attribute__ ((__destructor__))
+#endif
 XF86cleanup(int sig)
 {
     ScrPtr sp;
@@ -707,7 +706,9 @@ XF86DGAGetVideo(
 
     if (!beenHere) {
 	beenHere = 1;
+#ifndef __NetBSD__
 	atexit((void(*)(void))XF86cleanup);
+#endif
 	/* one shot XF86cleanup attempts */
 	signal(SIGSEGV, XF86cleanup);
 #ifdef SIGBUS
---

XF86cleanup() calls _exit(3) directly, so fflush(3) via
normal exit(3) is not called.

The following patch (by soda@, tweaked for xsrc HEAD by me) works around,
at least on my sun3/60 running NetBSD/sun3 9.1:

---
Index: external/mit/libXxf86dga/dist/src/XF86DGA.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/libXxf86dga/dist/src/XF86DGA.c,v
retrieving revision 1.2
diff -u -p -d -r1.2 XF86DGA.c
--- external/mit/libXxf86dga/dist/src/XF86DGA.c	4 Jan 2019 18:59:45 -0000	1.2
+++ external/mit/libXxf86dga/dist/src/XF86DGA.c	20 Jan 2021 11:37:18 -0000
@@ -650,14 +650,14 @@ static void
 #ifdef __NetBSD__
 __attribute__ ((__destructor__))
 #endif
-XF86cleanup(int sig)
+XF86cleanup_atexit(void)
 {
     ScrPtr sp;
     int i;
     static char beenhere = 0;
 
     if (beenhere)
-	_exit(3);
+	return;
     beenhere = 1;
 
     for (i = 0; i < numScrs; i++) {
@@ -665,6 +665,14 @@ XF86cleanup(int sig)
 	XF86DGADirectVideo(sp->display, sp->screen, 0);
 	XSync(sp->display, False);
     }
+}
+
+static void
+XF86cleanup(int sig)
+{
+    /* XXX FIXME XF86cleanup_atexit() is not async-signal-safe */
+    XF86cleanup_atexit();
+
     _exit(3);
 }
 

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index