On Mon, Aug 08, 2022 at 10:06:45PM +0200, Matthieu Herrb wrote:
> On Sun, Aug 07, 2022 at 03:38:06PM +0200, Matthieu Herrb wrote:
> > 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 ?
> 
> Ok, following the hint in the NetBSD report (start a few urxvt in
> ~/.xsession) I was able to reproduce
> the problem on fvwm2-2.6.9p1 and can confirm that my patches fix them.
> 
> ok?
> 
Hi,

looking a bit closer, the previous patch is incorrect. This one does
not mis Expose events.

But I still don't understand why the fvwm2 authors did so weird stuff
in their event loop. why is that need or which problem does it fix.

but if you use fvwm2 please test this patch and report success or
failure. (normally the current version in ports will sometimes crash
when several applications are started at launch time)

The same change needs to be applied to the fvwm3 patch.

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) ? 2 : 0;
++}
++
+ 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