On 18/10/2023 10:57, Stuart Henderson wrote:
On 2023/10/17 23:07, Ghislain Mercier wrote:
Hello,

With yesterday's upgrade from 7.3 to 7.4, and more specifically with
glib2 upgrading from 2.74.6 to 2.76.6, Openbox crashes when switching
out of a fullscreen window (tested on 7.4 GENERIC.MP#1397 amd64).

It appears to be a known bug, see
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1033385

I quote :
This bug has been reported upstream at
https://bugzilla.icculus.org/show_bug.cgi?id=6669.

The following patch is provided to fix the bug, and has been accepted
into a developer's work branch here:
http://git.openbox.org/?p=mikachu/openbox.git;a=commit;h=d41128e5a1002af41c976c8860f8299cfcd3cd72

I would be happy to provide a diff for the port but I have absolutely no
idea of how to do that... Of course, if one of the kind developers had
time to provide some guidance I could learn and try.

Thanks in advance !

GM.


CC'ing maintainer.

Not tested yet but I think this should do the trick.
If it works it would make sense to commit to 7.4-stable too.

ok benoit@


Index: Makefile
===================================================================
RCS file: /cvs/ports/x11/openbox/Makefile,v
retrieving revision 1.91
diff -u -p -r1.91 Makefile
--- Makefile    27 Sep 2023 20:37:19 -0000      1.91
+++ Makefile    18 Oct 2023 08:54:50 -0000
@@ -1,7 +1,7 @@
  COMMENT =     small, fast & usable window manager
V = 3.6.1
-REVISION =     11
+REVISION =     12
  DISTNAME =    openbox-${V}
  SHARED_LIBS +=        obrender        12.0    # 32.0
  SHARED_LIBS +=        obt             1.1     # 2.2
Index: patches/patch-openbox_client_c
===================================================================
RCS file: /cvs/ports/x11/openbox/patches/patch-openbox_client_c,v
retrieving revision 1.4
diff -u -p -r1.4 patch-openbox_client_c
--- patches/patch-openbox_client_c      11 Mar 2022 20:16:51 -0000      1.4
+++ patches/patch-openbox_client_c      18 Oct 2023 08:54:50 -0000
@@ -1,8 +1,25 @@
+First hunk, in client_get_settings_state():
+
  Fix a NULL pointer dereference that was causing a crash when launching
  Java GUI applications.
  From https://bugzilla.icculus.org/show_bug.cgi?id=5277 via Arch
  Linux.
+
+Others, in client_calc_layer():
+
+From d41128e5a1002af41c976c8860f8299cfcd3cd72 Mon Sep 17 00:00:00 2001
+From: pldubouilh <pldubou...@gmail.com>
+Date: Fri, 17 Mar 2023 18:23:47 +0100
+Subject: [PATCH] Fix list traversal issue in client_calc_layer
+
+The calls to client_calc_layer_internal can modify stacking_list, which
+can cause us to follow dangling ->next pointers (either by the pointer
+itself already being freed, or it pointing to a freed area). Avoid this
+by copying the list first, the goal is to visit every client in the list
+once so this should be fine.
+
+
  Index: openbox/client.c
  --- openbox/client.c.orig
  +++ openbox/client.c
@@ -15,3 +32,35 @@ Index: openbox/client.c
                    !g_pattern_match(app->title,
                                     strlen(self->title), self->title, NULL))
               match = FALSE;
+@@ -2702,9 +2702,12 @@ static void client_calc_layer_internal(ObClient *self)
+ void client_calc_layer(ObClient *self)
+ {
+     GList *it;
++    /* the client_calc_layer_internal calls below modify stacking_list,
++       so we have to make a copy to iterate over */
++    GList *list = g_list_copy(stacking_list);
+
+     /* skip over stuff above fullscreen layer */
+-    for (it = stacking_list; it; it = g_list_next(it))
++    for (it = list; it; it = g_list_next(it))
+         if (window_layer(it->data) <= OB_STACKING_LAYER_FULLSCREEN) break;
+
+     /* find the windows in the fullscreen layer, and mark them not-visited */
+@@ -2717,7 +2720,7 @@ void client_calc_layer(ObClient *self)
+     client_calc_layer_internal(self);
+
+     /* skip over stuff above fullscreen layer */
+-    for (it = stacking_list; it; it = g_list_next(it))
++    for (it = list; it; it = g_list_next(it))
+         if (window_layer(it->data) <= OB_STACKING_LAYER_FULLSCREEN) break;
+
+     /* now recalc any windows in the fullscreen layer which have not
+@@ -2728,6 +2731,8 @@ void client_calc_layer(ObClient *self)
+                  !WINDOW_AS_CLIENT(it->data)->visited)
+             client_calc_layer_internal(it->data);
+     }
++
++    g_list_free(it);
+ }
+
+ gboolean client_should_show(ObClient *self)


Reply via email to