From ea04f722f911090396ed7f9642e625516e2a44dd Mon Sep 17 00:00:00 2001 From: lvgenggeng Date: Wed, 8 Nov 2023 14:35:28 +0800 Subject: [PATCH] backport patches from upstream Signed-off-by: lvgenggeng --- ...es-when-using-machine-criterion-5650.patch | 34 +++++++++ ...ng-memory-issue-copy-current_binding.patch | 34 +++++++++ ...allocations-to-satisfy-LeakSanitizer.patch | 70 +++++++++++++++++++ i3.spec | 8 ++- 4 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 backport-Fix-crashes-when-using-machine-criterion-5650.patch create mode 100644 backport-fix-reload-binding-memory-issue-copy-current_binding.patch create mode 100644 backport-free-some-heap-allocations-to-satisfy-LeakSanitizer.patch diff --git a/backport-Fix-crashes-when-using-machine-criterion-5650.patch b/backport-Fix-crashes-when-using-machine-criterion-5650.patch new file mode 100644 index 0000000..17ebe5f --- /dev/null +++ b/backport-Fix-crashes-when-using-machine-criterion-5650.patch @@ -0,0 +1,34 @@ +From c6f62f4695ae66cf0fea498c7ac4ab21ba68faae Mon Sep 17 00:00:00 2001 +From: Orestis Floros +Date: Sun, 3 Sep 2023 19:32:42 +0200 +Subject: [PATCH 1/1] Fix crashes when using machine criterion (#5650) + +Fixes #5616 +--- + release-notes/bugfixes/4-machine-crash | 1 + + src/match.c | 1 + + 2 files changed, 2 insertions(+) + create mode 100644 release-notes/bugfixes/4-machine-crash + +diff --git a/release-notes/bugfixes/4-machine-crash b/release-notes/bugfixes/4-machine-crash +new file mode 100644 +index 00000000..24dc04ee +--- /dev/null ++++ b/release-notes/bugfixes/4-machine-crash +@@ -0,0 +1 @@ ++fix crashes when using machine criterion +diff --git a/src/match.c b/src/match.c +index 34314e25..cfd7d324 100644 +--- a/src/match.c ++++ b/src/match.c +@@ -80,6 +80,7 @@ void match_copy(Match *dest, Match *src) { + DUPLICATE_REGEX(instance); + DUPLICATE_REGEX(window_role); + DUPLICATE_REGEX(workspace); ++ DUPLICATE_REGEX(machine); + } + + /* +-- +2.20.1 + diff --git a/backport-fix-reload-binding-memory-issue-copy-current_binding.patch b/backport-fix-reload-binding-memory-issue-copy-current_binding.patch new file mode 100644 index 0000000..7f56b94 --- /dev/null +++ b/backport-fix-reload-binding-memory-issue-copy-current_binding.patch @@ -0,0 +1,34 @@ +From dfb38509898881af408c80d97904a2736d495931 Mon Sep 17 00:00:00 2001 +From: Michael Stapelberg +Date: Mon, 2 Jan 2023 11:05:55 +0100 +Subject: [PATCH 1/1] fix reload binding memory issue: copy + current_binding_mode + +--- + src/bindings.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/bindings.c b/src/bindings.c +index 4cb916fa..2c8d5970 100644 +--- a/src/bindings.c ++++ b/src/bindings.c +@@ -845,7 +845,7 @@ CommandResult *run_binding(Binding *bind, Con *con) { + Binding *bind_cp = binding_copy(bind); + /* The "mode" command might change the current mode, so back it up to + * correctly produce an event later. */ +- const char *modename = current_binding_mode; ++ char *modename = sstrdup(current_binding_mode); + + CommandResult *result = parse_command(command, NULL, NULL); + free(command); +@@ -873,6 +873,7 @@ CommandResult *run_binding(Binding *bind, Con *con) { + } + + ipc_send_binding_event("run", bind_cp, modename); ++ FREE(modename); + binding_free(bind_cp); + + return result; +-- +2.20.1 + diff --git a/backport-free-some-heap-allocations-to-satisfy-LeakSanitizer.patch b/backport-free-some-heap-allocations-to-satisfy-LeakSanitizer.patch new file mode 100644 index 0000000..166e220 --- /dev/null +++ b/backport-free-some-heap-allocations-to-satisfy-LeakSanitizer.patch @@ -0,0 +1,70 @@ +From aaee2b3eaefcb42414d72cbcf656eae06c3adb75 Mon Sep 17 00:00:00 2001 +From: Michael Stapelberg +Date: Mon, 2 Jan 2023 11:33:22 +0100 +Subject: [PATCH 1/1] free some heap allocations to satisfy LeakSanitizer + +--- + src/main.c | 22 +++++++++++++++------- + 1 file changed, 15 insertions(+), 7 deletions(-) + +diff --git a/src/main.c b/src/main.c +index 6d6b9c9c..f679966f 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -1002,10 +1002,11 @@ int main(int argc, char *argv[]) { + char *log_stream_socket_path = get_process_filename("log-stream-socket"); + int log_socket = create_socket(log_stream_socket_path, ¤t_log_stream_socket_path); + free(log_stream_socket_path); ++ struct ev_io *log_io = NULL; + if (log_socket == -1) { + ELOG("Could not create the log socket, i3-dump-log -f will not work\n"); + } else { +- struct ev_io *log_io = scalloc(1, sizeof(struct ev_io)); ++ log_io = scalloc(1, sizeof(struct ev_io)); + ev_io_init(log_io, log_new_client, log_socket, EV_READ); + ev_io_start(main_loop, log_io); + } +@@ -1013,12 +1014,13 @@ int main(int argc, char *argv[]) { + /* Also handle the UNIX domain sockets passed via socket + * activation. The parameter 0 means "do not remove the + * environment variables", we need to be able to reexec. */ ++ struct ev_io *socket_ipc_io = NULL; + listen_fds = sd_listen_fds(0); +- if (listen_fds < 0) ++ if (listen_fds < 0) { + ELOG("socket activation: Error in sd_listen_fds\n"); +- else if (listen_fds == 0) ++ } else if (listen_fds == 0) { + DLOG("socket activation: no sockets passed\n"); +- else { ++ } else { + int flags; + for (int fd = SD_LISTEN_FDS_START; + fd < (SD_LISTEN_FDS_START + listen_fds); +@@ -1033,9 +1035,9 @@ int main(int argc, char *argv[]) { + ELOG("Could not disable FD_CLOEXEC on fd %d\n", fd); + } + +- struct ev_io *ipc_io = scalloc(1, sizeof(struct ev_io)); +- ev_io_init(ipc_io, ipc_new_client, fd, EV_READ); +- ev_io_start(main_loop, ipc_io); ++ socket_ipc_io = scalloc(1, sizeof(struct ev_io)); ++ ev_io_init(socket_ipc_io, ipc_new_client, fd, EV_READ); ++ ev_io_start(main_loop, socket_ipc_io); + } + } + +@@ -1198,4 +1200,10 @@ int main(int argc, char *argv[]) { + + sd_notify(1, "READY=1"); + ev_loop(main_loop, 0); ++ ++ /* Free these heap allocations just to satisfy LeakSanitizer. */ ++ FREE(ipc_io); ++ FREE(socket_ipc_io); ++ FREE(log_io); ++ FREE(xcb_watcher); + } +-- +2.20.1 + diff --git a/i3.spec b/i3.spec index 27b973e..32758a1 100644 --- a/i3.spec +++ b/i3.spec @@ -1,6 +1,6 @@ Name: i3 Version: 4.22 -Release: 1 +Release: 2 Summary: Improved tiling window manager License: BSD-3-Clause URL: https://i3wm.org @@ -8,6 +8,9 @@ Source0: %{URL}/downloads/%{name}-%{version}.tar.xz Source1: %{URL}/downloads/%{name}-%{version}.tar.xz.asc Source2: gpgkey-424E14D703E7C6D43D9D6F364E7160ED4AC8EE1D.gpg Source3: %{name}-logo.svg +Patch0: backport-fix-reload-binding-memory-issue-copy-current_binding.patch +Patch1: backport-free-some-heap-allocations-to-satisfy-LeakSanitizer.patch +Patch2: backport-Fix-crashes-when-using-machine-criterion-5650.patch # i3-gaps was merged into i3 with 4.22 Provides: i3-gaps = %{version}-%{release} @@ -171,5 +174,8 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/i3.desktop %doc pseudo-doc/doxygen/ %changelog +* Wed Nov 08 2023 lvgenggeng - 4.22-2 +- backport patches from upstream + * Fri Feb 10 2023 lichaoran - 4.22-1 - Initial packaging