Hi,

I've received a report that fvwm2 is abort(2)ing under -current, since
the import of libX11 1.8.1. The backtrace associated with this report
shows that it's the same issue that I fixed in xfce4-settings
earlier.

Unfortunatly, I can't reproduce the crash with the default fvwm2
configuration on my machines so I can't confirm if the patch below is
enough to completely fix the issue. I'm still waiting for a report
from the original reporter.

(There is also a NetBSD report that's probably caused by the same
issue: https://marc.infœ?l=netbsd-current-users&m=165902977815467&w=2)

Did anyone else here stumble on fvwm2 aborting since libX11 1.8.2 was
imported (approxymatly july 25 snapshots) ? if so can you try the
patch below ?

PS: x11/fvwm3 will need a very similar change. If you see the issue
with fvwm3, please try to adapt the patch and report.

Index: Makefile
===================================================================
RCS file: /cvs/OpenBSD/ports/x11/fvwm2/Makefile,v
retrieving revision 1.73
diff -u -p -u -r1.73 Makefile
--- Makefile    29 Jul 2022 07:45:04 -0000      1.73
+++ Makefile    7 Aug 2022 13:11:02 -0000
@@ -1,7 +1,7 @@
 COMMENT=       multiple virtual desktop window manager
 
 VERSION=       2.6.9
-REVISION=      1
+REVISION=      2
 DISTNAME=      fvwm-${VERSION}
 PKGNAME=       fvwm2-${VERSION}
 
Index: patches/patch-fvwm_events_c
===================================================================
RCS file: patches/patch-fvwm_events_c
diff -N patches/patch-fvwm_events_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-fvwm_events_c 7 Aug 2022 13:21:18 -0000
@@ -0,0 +1,28 @@
+Fix for XCheckIfEvent() callback lock recursion
+
+Index: fvwm/events.c
+--- fvwm/events.c.orig
++++ fvwm/events.c
+@@ -258,6 +258,12 @@ static int _pred_weed_accumulate_expose(
+       return 1;
+ }
+ 
++static int _pred_weed_is_expose(
++      Display *display, XEvent *event, XPointer arg)
++{
++      return (event->type == Expose);
++}
++
+ static int _pred_weed_handle_expose(
+       Display *display, XEvent *event, XPointer arg)
+ {
+@@ -4542,7 +4548,8 @@ void handle_all_expose(void)
+ 
+       saved_event = fev_save_event();
+       FPending(dpy);
+-      FWeedIfEvents(dpy, _pred_weed_handle_expose, NULL);
++      FWeedAndHandleIfEvents(dpy, _pred_weed_is_expose,
++                             _pred_weed_handle_expose, NULL);
+       fev_restore_event(saved_event);
+ 
+       return;
Index: patches/patch-libs_FEvent_c
===================================================================
RCS file: patches/patch-libs_FEvent_c
diff -N patches/patch-libs_FEvent_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-libs_FEvent_c 7 Aug 2022 13:21:18 -0000
@@ -0,0 +1,34 @@
+Fix for XCheckIfEvent() callback lock recursion
+
+Index: libs/FEvent.c
+--- libs/FEvent.c.orig
++++ libs/FEvent.c
+@@ -532,6 +532,28 @@ int FWeedIfEvents(
+       return weed_args.count;
+ }
+ 
++int FWeedAndHandleIfEvents(
++      Display *display,
++      int (*weed_predicate) (Display *display, XEvent *event, XPointer arg),
++      int (*handler) (Display *display, XEvent *event, XPointer arg),
++      XPointer arg)
++{
++      _fev_weed_args weed_args;
++      XEvent e;
++
++      assert(fev_is_invalid_event_type_set);
++      memset(&weed_args, 0, sizeof(weed_args));
++      weed_args.weed_predicate = weed_predicate;
++      weed_args.arg = arg;
++      if (FCheckPeekIfEvent(display, &e, _fev_pred_weed_if,
++                            (XPointer)&weed_args)) {
++              handler(display, &e, arg);
++      }
++      _fev_pred_weed_if_finish(&weed_args);
++
++      return weed_args.count;
++}
++
+ int FWeedIfWindowEvents(
+       Display *display, Window window,
+       int (*weed_predicate) (
Index: patches/patch-libs_FEvent_h
===================================================================
RCS file: patches/patch-libs_FEvent_h
diff -N patches/patch-libs_FEvent_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-libs_FEvent_h 7 Aug 2022 13:11:02 -0000
@@ -0,0 +1,20 @@
+Fix for XCheckIfEvent() callback lock recursion
+
+Index: libs/FEvent.h
+--- libs/FEvent.h.orig
++++ libs/FEvent.h
+@@ -113,6 +113,14 @@ int FWeedIfEvents(
+               Display *display, XEvent *current_event, XPointer arg),
+       XPointer arg);
+ 
++/* Same as FWeedIfEvents but with a second callback out of XLockDisplay()
++ * to handle events in a lock-safe manner */
++int FWeedAndHandleIfEvents(
++      Display *display,
++      int (*weed_predicate) (Display *display, XEvent *event, XPointer arg),
++      int (*handler) (Display *display, XEvent *event, XPointer arg),
++      XPointer arg);
++
+ /* Same as FWeedIfEvents but weeds only events for the given window.  The
+  * weed_predicate is only called for events with a matching window.  */
+ int FWeedIfWindowEvents(

-- 
Matthieu Herrb

Reply via email to