From 4704c9a6fcf1d8c224bdc4d48364f5c03031ee2c Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 26 Aug 2021 11:06:59 -0700 Subject: [PATCH 1/2] Lock X updates for all systems and lock around X cleanup at exit All systems which could generate I/O interrupts on the X file descriptor need to have locking enabled, or there is a high probability that the X library will deadlock. This requirement may be removed in the future with restructuring of the way that the interrupt driven I/O is handled. Ensure that the appropriate XLOCK/XUNLOCK is done around the X window closing code. --- bin/makefile-cygwin.x86_64-x | 2 +- bin/makefile-darwin.386-x | 2 +- bin/makefile-darwin.aarch64-x | 2 +- bin/makefile-darwin.ppc-x | 2 +- bin/makefile-darwin.x86_64-x | 2 +- bin/makefile-init-darwin.386 | 2 +- bin/makefile-init-darwin.aarch64 | 2 +- bin/makefile-init-darwin.x86_64 | 2 +- bin/makefile-init-linux.x86_64 | 2 +- bin/makefile-init-sunos5.sparc | 2 +- bin/makefile-linux.386-x | 2 +- bin/makefile-linux.aarch64-x | 2 +- bin/makefile-linux.armv7l-x | 2 +- bin/makefile-linux.x86_64-x | 2 +- bin/makefile-openbsd.x86_64-x | 2 +- bin/makefile-sunos5.386-x | 2 +- bin/makefile-sunos5.i386-x | 2 +- bin/makefile-sunos5.sparc-x | 2 +- bin/makefile-sunos5.x86_64-x | 2 +- src/xinit.c | 4 +++- 20 files changed, 22 insertions(+), 20 deletions(-) diff --git a/bin/makefile-cygwin.x86_64-x b/bin/makefile-cygwin.x86_64-x index f280cbad..8129feba 100644 --- a/bin/makefile-cygwin.x86_64-x +++ b/bin/makefile-cygwin.x86_64-x @@ -14,7 +14,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 diff --git a/bin/makefile-darwin.386-x b/bin/makefile-darwin.386-x index 7cb52d32..51257374 100644 --- a/bin/makefile-darwin.386-x +++ b/bin/makefile-darwin.386-x @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -I/opt/X11/include -DXWINDOW +XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g diff --git a/bin/makefile-darwin.aarch64-x b/bin/makefile-darwin.aarch64-x index a92219fa..f8f59e78 100644 --- a/bin/makefile-darwin.aarch64-x +++ b/bin/makefile-darwin.aarch64-x @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -I/opt/X11/include -DXWINDOW +XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 diff --git a/bin/makefile-darwin.ppc-x b/bin/makefile-darwin.ppc-x index 50db58fa..8d35749b 100644 --- a/bin/makefile-darwin.ppc-x +++ b/bin/makefile-darwin.ppc-x @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -I/usr/X11/include -DXWINDOW +XFLAGS = -I/usr/X11/include -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g diff --git a/bin/makefile-darwin.x86_64-x b/bin/makefile-darwin.x86_64-x index e17f10bc..0ac392bd 100644 --- a/bin/makefile-darwin.x86_64-x +++ b/bin/makefile-darwin.x86_64-x @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -I/opt/X11/include -DXWINDOW +XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O1 -g diff --git a/bin/makefile-init-darwin.386 b/bin/makefile-init-darwin.386 index c7aaa62d..fbd168d1 100644 --- a/bin/makefile-init-darwin.386 +++ b/bin/makefile-init-darwin.386 @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -I/opt/X11/include -DXWINDOW +XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it OPTFLAGS = -O0 -g diff --git a/bin/makefile-init-darwin.aarch64 b/bin/makefile-init-darwin.aarch64 index 1314d4f3..c81744d8 100644 --- a/bin/makefile-init-darwin.aarch64 +++ b/bin/makefile-init-darwin.aarch64 @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -I/opt/X11/include -DXWINDOW +XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O0 -g3 diff --git a/bin/makefile-init-darwin.x86_64 b/bin/makefile-init-darwin.x86_64 index 322b4a84..943e9032 100644 --- a/bin/makefile-init-darwin.x86_64 +++ b/bin/makefile-init-darwin.x86_64 @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -I/opt/X11/include -DXWINDOW +XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O0 -g diff --git a/bin/makefile-init-linux.x86_64 b/bin/makefile-init-linux.x86_64 index 8d696ddc..3f64a502 100644 --- a/bin/makefile-init-linux.x86_64 +++ b/bin/makefile-init-linux.x86_64 @@ -14,7 +14,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it OPTFLAGS = -O0 -g diff --git a/bin/makefile-init-sunos5.sparc b/bin/makefile-init-sunos5.sparc index c8ced0bd..69f89972 100644 --- a/bin/makefile-init-sunos5.sparc +++ b/bin/makefile-init-sunos5.sparc @@ -30,7 +30,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xrdopt.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -g for MAKEINIT, as it needs debugging often. OPTFLAGS = -g3 -O0 diff --git a/bin/makefile-linux.386-x b/bin/makefile-linux.386-x index b25198d8..37fb1852 100644 --- a/bin/makefile-linux.386-x +++ b/bin/makefile-linux.386-x @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 diff --git a/bin/makefile-linux.aarch64-x b/bin/makefile-linux.aarch64-x index 1f2f1569..c6db5f18 100644 --- a/bin/makefile-linux.aarch64-x +++ b/bin/makefile-linux.aarch64-x @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xrdopt.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 diff --git a/bin/makefile-linux.armv7l-x b/bin/makefile-linux.armv7l-x index 1f2f1569..c6db5f18 100644 --- a/bin/makefile-linux.armv7l-x +++ b/bin/makefile-linux.armv7l-x @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xrdopt.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 diff --git a/bin/makefile-linux.x86_64-x b/bin/makefile-linux.x86_64-x index f280cbad..8129feba 100644 --- a/bin/makefile-linux.x86_64-x +++ b/bin/makefile-linux.x86_64-x @@ -14,7 +14,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 diff --git a/bin/makefile-openbsd.x86_64-x b/bin/makefile-openbsd.x86_64-x index b95e5f50..70a1798f 100644 --- a/bin/makefile-openbsd.x86_64-x +++ b/bin/makefile-openbsd.x86_64-x @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -I/usr/X11R6/include -DXWINDOW +XFLAGS = -I/usr/X11R6/include -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 diff --git a/bin/makefile-sunos5.386-x b/bin/makefile-sunos5.386-x index b22e33b1..f1c7b780 100644 --- a/bin/makefile-sunos5.386-x +++ b/bin/makefile-sunos5.386-x @@ -22,7 +22,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xrdopt.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g diff --git a/bin/makefile-sunos5.i386-x b/bin/makefile-sunos5.i386-x index 74a8bb62..8831073d 100644 --- a/bin/makefile-sunos5.i386-x +++ b/bin/makefile-sunos5.i386-x @@ -22,7 +22,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xrdopt.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 diff --git a/bin/makefile-sunos5.sparc-x b/bin/makefile-sunos5.sparc-x index 931d2286..a9304cc4 100644 --- a/bin/makefile-sunos5.sparc-x +++ b/bin/makefile-sunos5.sparc-x @@ -29,7 +29,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xrdopt.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 diff --git a/bin/makefile-sunos5.x86_64-x b/bin/makefile-sunos5.x86_64-x index 923544df..3f8ab9fd 100644 --- a/bin/makefile-sunos5.x86_64-x +++ b/bin/makefile-sunos5.x86_64-x @@ -22,7 +22,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \ $(OBJECTDIR)xrdopt.o \ $(OBJECTDIR)xwinman.o -XFLAGS = -DXWINDOW +XFLAGS = -DXWINDOW -DLOCK_X_UPDATES # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g diff --git a/src/xinit.c b/src/xinit.c index 938935ee..d47c8d91 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -108,13 +108,15 @@ void lisp_Xexit(DspInterface dsp) { assert(Lisp_Xinitialized); -#if defined(OS5) && defined(I_SETSIG) +#if defined(I_SETSIG) ioctl(ConnectionNumber(dsp->display_id), I_SETSIG, 0); /* so no interrupts happen during */ #endif + XLOCK; XDestroySubwindows(dsp->display_id, dsp->LispWindow); XDestroyWindow(dsp->display_id, dsp->LispWindow); XCloseDisplay(dsp->display_id); + XUNLOCK(dsp); Lisp_Xinitialized = false; } /* end lisp_Xexit */ From 37c2883c3a8c886d1847092b4d7e41e1c3c31fd4 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 26 Aug 2021 11:28:33 -0700 Subject: [PATCH 2/2] Also lock X updates when building with CMake. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b879331f..7f95454d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ OPTION(MAIKO_DISPLAY_X11 "Use X11 for display." ON) IF(MAIKO_DISPLAY_X11) FIND_PACKAGE(X11 REQUIRED) SET(MAIKO_DISPLAY_X11_DEFINITIONS - "-DXWINDOW" + "-DXWINDOW -DLOCK_X_UPDATES" ) SET(MAIKO_DISPLAY_X11_LIBRARIES X11::X11) SET(MAIKO_DISPLAY_X11_SRCS