From f01b625535599954bccdca177e5dae38814516f1 Mon Sep 17 00:00:00 2001 From: Peter Lemenkov Date: Jan 21 2024 13:04:53 +0000 Subject: Fix crashes Signed-off-by: Peter Lemenkov --- diff --git a/fvwm-0005-Fix-for-lock-recusion-in-handle_all_expose.patch b/fvwm-0005-Fix-for-lock-recusion-in-handle_all_expose.patch new file mode 100644 index 0000000..7558f4d --- /dev/null +++ b/fvwm-0005-Fix-for-lock-recusion-in-handle_all_expose.patch @@ -0,0 +1,94 @@ +From: Matthieu Herrb +Date: Mon, 8 Aug 2022 22:13:59 +0200 +Subject: [PATCH] Fix for lock recusion in handle_all_expose() + +XCheckIfEvent() holds the X display lock and the predicate +function it calls is not allowed to call any Xlib function that +would re-enter the lock. +libX11 1.8.1 enables X display locks unconditionnaly (it was only +enabled by XInitThreads() when called explicitely before) and +thus exposes the issue. + +So don't process events in the FCheckPeekIfEvent() predicate, but +instead use a separate handler that is called for the returned event +out of the lock. + +diff --git a/fvwm/events.c b/fvwm/events.c +index a2d02406..7a3d06c3 100644 +--- a/fvwm/events.c ++++ b/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; +diff --git a/libs/FEvent.c b/libs/FEvent.c +index 24d019dd..ec31728a 100644 +--- a/libs/FEvent.c ++++ b/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) ( +diff --git a/libs/FEvent.h b/libs/FEvent.h +index 821aef51..2622f447 100644 +--- a/libs/FEvent.h ++++ b/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( diff --git a/fvwm-0006-Fixes-for-C99-compatibility.patch b/fvwm-0006-Fixes-for-C99-compatibility.patch new file mode 100644 index 0000000..7131153 --- /dev/null +++ b/fvwm-0006-Fixes-for-C99-compatibility.patch @@ -0,0 +1,50 @@ +From: Florian Weimer +Date: Thu, 24 Nov 2022 13:10:29 +0100 +Subject: [PATCH] Fixes for C99 compatibility + +Do not check that the compiler supports implicit ints without errors. +Add a missing #include . + +Submitted upstream: + +Related to: + + + + +diff --git a/acinclude.m4 b/acinclude.m4 +index 8b74ff1e..4dee2abe 100644 +--- a/acinclude.m4 ++++ b/acinclude.m4 +@@ -30,7 +30,7 @@ if test "$ac_cv_func_select" = yes; then + #ifdef HAVE_SYS_SOCKET_H + #include + #endif], +-[extern select ($ac_cv_type_fd_set_size_t, ++[extern int select ($ac_cv_type_fd_set_size_t, + $ac_cv_type_fd_set *, $ac_cv_type_fd_set *, $ac_cv_type_fd_set *, + $ac_type_timeval *);], + [ac_found=yes ; break 3],ac_found=no) +@@ -1154,6 +1154,9 @@ AC_DEFUN([AM_SAFETY_CHECK_MKSTEMP],[ + #include + #include + #include ++#ifdef HAVE_UNISTD_H ++#include ++#endif + int main(void) + { + char template[128]; +diff --git a/configure.ac b/configure.ac +index 1389d564..cd73b925 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -220,7 +220,7 @@ AC_MINIX + + # catch -Werror and similar options when running configure + AC_TRY_COMPILE([#include ], +-[int i; static j; int *p; char *c; ++[int i; int *p; char *c; + switch (*p = p = *c) { case 0: printf("%Q", c, p); } + *c = &i; c = p; + while (1 || (unsigned int)3 >= 0 || ((int)-1) == ((unsigned int)1)); diff --git a/fvwm-0007-Fixes-for-C99-compatibility.patch b/fvwm-0007-Fixes-for-C99-compatibility.patch new file mode 100644 index 0000000..472411b --- /dev/null +++ b/fvwm-0007-Fixes-for-C99-compatibility.patch @@ -0,0 +1,32 @@ +From: Florian Weimer +Date: Thu, 24 Nov 2022 13:10:29 +0100 +Subject: [PATCH] Fixes for C99 compatibility + +Incompatible pointer types are actually errors (in the sense +that they are invalid C). Compilers have merely tolerated them as +warnings for backwards compatibility. This is changing with Clang 16 +and GCC 14, so relax the check a little. + +Submitted upstream: + +Related to: + + + + +diff --git a/configure.ac b/configure.ac +index cd73b925..974c2c0e 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -220,9 +220,8 @@ AC_MINIX + + # catch -Werror and similar options when running configure + AC_TRY_COMPILE([#include ], +-[int i; int *p; char *c; +- switch (*p = p = *c) { case 0: printf("%Q", c, p); } +- *c = &i; c = p; ++[int unused; int *p; char *c; ++ printf("%Q", c, p); + while (1 || (unsigned int)3 >= 0 || ((int)-1) == ((unsigned int)1)); + ], , AC_MSG_ERROR(" + configure is not able to compile programs with warnings. Please diff --git a/fvwm-configure-c99-2.patch b/fvwm-configure-c99-2.patch deleted file mode 100644 index 2f80a17..0000000 --- a/fvwm-configure-c99-2.patch +++ /dev/null @@ -1,23 +0,0 @@ -Incompatible pointer types are actually errors (in the sense -that they are invalid C). Compilers have merely tolerated them as -warnings for backwards compatibility. This is changing with Clang 16 -and GCC 14, so relax the check a little. - -Submitted upstream: - -diff --git a/configure.ac b/configure.ac -index cd73b925dc077141..974c2c0ed6a70b0f 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -220,9 +220,8 @@ AC_MINIX - - # catch -Werror and similar options when running configure - AC_TRY_COMPILE([#include ], --[int i; int *p; char *c; -- switch (*p = p = *c) { case 0: printf("%Q", c, p); } -- *c = &i; c = p; -+[int unused; int *p; char *c; -+ printf("%Q", c, p); - while (1 || (unsigned int)3 >= 0 || ((int)-1) == ((unsigned int)1)); - ], , AC_MSG_ERROR(" - configure is not able to compile programs with warnings. Please diff --git a/fvwm-configure-c99.patch b/fvwm-configure-c99.patch deleted file mode 100644 index 728c873..0000000 --- a/fvwm-configure-c99.patch +++ /dev/null @@ -1,41 +0,0 @@ -Do not check that the compiler supports implicit ints without errors. -Add a missing #include . - -Submitted upstream: - -diff --git a/acinclude.m4 b/acinclude.m4 -index 8b74ff1e5be21f6d..4dee2abebc678358 100644 ---- a/acinclude.m4 -+++ b/acinclude.m4 -@@ -30,7 +30,7 @@ if test "$ac_cv_func_select" = yes; then - #ifdef HAVE_SYS_SOCKET_H - #include - #endif], --[extern select ($ac_cv_type_fd_set_size_t, -+[extern int select ($ac_cv_type_fd_set_size_t, - $ac_cv_type_fd_set *, $ac_cv_type_fd_set *, $ac_cv_type_fd_set *, - $ac_type_timeval *);], - [ac_found=yes ; break 3],ac_found=no) -@@ -1154,6 +1154,9 @@ AC_DEFUN([AM_SAFETY_CHECK_MKSTEMP],[ - #include - #include - #include -+#ifdef HAVE_UNISTD_H -+#include -+#endif - int main(void) - { - char template[128]; -diff --git a/configure.ac b/configure.ac -index 1389d5643653aa8e..cd73b925dc077141 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -220,7 +220,7 @@ AC_MINIX - - # catch -Werror and similar options when running configure - AC_TRY_COMPILE([#include ], --[int i; static j; int *p; char *c; -+[int i; int *p; char *c; - switch (*p = p = *c) { case 0: printf("%Q", c, p); } - *c = &i; c = p; - while (1 || (unsigned int)3 >= 0 || ((int)-1) == ((unsigned int)1)); diff --git a/fvwm.spec b/fvwm.spec index a005b4b..a6b1ff7 100644 --- a/fvwm.spec +++ b/fvwm.spec @@ -1,6 +1,6 @@ Name: fvwm Version: 2.7.0 -Release: 6%{?dist} +Release: %autorelease Summary: Highly configurable multiple virtual desktop window manager License: GPLv2+ URL: https://www.fvwm.org/ @@ -12,8 +12,12 @@ Patch2: fvwm-0002-Use-mimeopen-instead-of-EDITOR.patch Patch3: fvwm-0003-FvwmPager-be-more-careful-with-window-labels.patch # Fedora-specific Patch4: fvwm-0004-Skip-install-data-hook-for-default-configs.patch -Patch5: fvwm-configure-c99.patch -Patch6: fvwm-configure-c99-2.patch +# Backported from https://github.com/fvwmorg/fvwm3/pull/683 +Patch5: fvwm-0005-Fix-for-lock-recusion-in-handle_all_expose.patch +# Suvbmitted upstream as https://github.com/fvwmorg/fvwm/pull/100 +Patch6: fvwm-0006-Fixes-for-C99-compatibility.patch +# Suvbmitted upstream as https://github.com/fvwmorg/fvwm/pull/100 +Patch7: fvwm-0007-Fixes-for-C99-compatibility.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: fribidi-devel