From e0872823f1f4825423ee2d480054e5065555247b Mon Sep 17 00:00:00 2001 From: han_hui_hui Date: Thu, 11 Jan 2024 03:26:55 +0000 Subject: [PATCH] fix memory leak and log domains error --- ...sk-is-freed-on-a-graceful-disconnect.patch | 39 ++++++ ...-fix-dropping-irrelevant-log-domains.patch | 128 ++++++++++++++++++ ...-minor-leak-in-g_build_user_data_dir.patch | 31 +++++ glib2.spec | 9 +- 4 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 backport-Make-sure-the-GTask-is-freed-on-a-graceful-disconnect.patch create mode 100644 backport-gmessages-fix-dropping-irrelevant-log-domains.patch create mode 100644 backport-gutils-Fix-an-unlikely-minor-leak-in-g_build_user_data_dir.patch diff --git a/backport-Make-sure-the-GTask-is-freed-on-a-graceful-disconnect.patch b/backport-Make-sure-the-GTask-is-freed-on-a-graceful-disconnect.patch new file mode 100644 index 0000000..6ed1df6 --- /dev/null +++ b/backport-Make-sure-the-GTask-is-freed-on-a-graceful-disconnect.patch @@ -0,0 +1,39 @@ +From cabc49407371800733ada202fab721c9091b6fe6 Mon Sep 17 00:00:00 2001 +From: Pavel Sobolev +Date: Thu, 14 Sep 2023 15:42:24 +0300 +Subject: [PATCH] Make sure the `GTask` is freed on a graceful disconnect + +This fixes the memory leak in the case the connection has been +successfully closed by the peer. + + +Conflict:NA +Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/cabc49407371800733ada202fab721c9091b6fe6 + +--- + gio/gtcpconnection.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gio/gtcpconnection.c b/gio/gtcpconnection.c +index 422b3dea52..e0865d859b 100644 +--- a/gio/gtcpconnection.c ++++ b/gio/gtcpconnection.c +@@ -206,6 +206,8 @@ async_close_finish (GTask *task, + g_task_return_error (task, error); + else + g_task_return_boolean (task, TRUE); ++ ++ g_object_unref (task); + } + + +@@ -231,7 +233,6 @@ close_read_ready (GSocket *socket, + else + { + async_close_finish (task, error); +- g_object_unref (task); + return FALSE; + } + } +-- +GitLab \ No newline at end of file diff --git a/backport-gmessages-fix-dropping-irrelevant-log-domains.patch b/backport-gmessages-fix-dropping-irrelevant-log-domains.patch new file mode 100644 index 0000000..a92864a --- /dev/null +++ b/backport-gmessages-fix-dropping-irrelevant-log-domains.patch @@ -0,0 +1,128 @@ +From 71f6d4c129fc729a5ead08637924d8c0973f2fe9 Mon Sep 17 00:00:00 2001 +From: Alexander Slobodeniuk +Date: Wed, 1 Nov 2023 10:32:27 +0100 +Subject: [PATCH 1/2] gmessages: fix dropping irrelevant log domains + +If the string of one log domain is contained in +another, it was printing both. + +For example, if G_MESSAGES_DEBUG is "Gtkspecial", +it would also keep the logs of the "Gtk" domain + +Conflict:NA +Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/71f6d4c129fc729a5ead08637924d8c0973f2fe9 + +--- + glib/gmessages.c | 22 +++++++++++++++++++++- + 1 file changed, 21 insertions(+), 1 deletion(-) + +diff --git a/glib/gmessages.c b/glib/gmessages.c +index d0d38c925a..ebd3a5433e 100644 +--- a/glib/gmessages.c ++++ b/glib/gmessages.c +@@ -2465,6 +2465,26 @@ log_is_old_api (const GLogField *fields, + g_strcmp0 (fields[0].value, "1") == 0); + } + ++static gboolean ++domain_found (const gchar *domains, ++ const char *log_domain) ++{ ++ guint len; ++ const gchar *found; ++ ++ len = strlen (log_domain); ++ ++ for (found = strstr (domains, log_domain); found; ++ found = strstr (found + 1, log_domain)) ++ { ++ if ((found == domains || found[-1] == ' ') ++ && (found[len] == 0 || found[len] == ' ')) ++ return TRUE; ++ } ++ ++ return FALSE; ++} ++ + /* + * Internal version of g_log_writer_default_would_drop(), which can + * read from either a log_domain or an array of fields. This avoids +@@ -2504,7 +2524,7 @@ should_drop_message (GLogLevelFlags log_level, + } + + if (strcmp (domains, "all") != 0 && +- (log_domain == NULL || !strstr (domains, log_domain))) ++ (log_domain == NULL || !domain_found (domains, log_domain))) + return TRUE; + } + +-- +GitLab + + +From 8eddbb9832b9a52a7495cc380e53715d920bb9ea Mon Sep 17 00:00:00 2001 +From: Alexander Slobodeniuk +Date: Wed, 1 Nov 2023 19:23:35 +0100 +Subject: [PATCH 2/2] glib/tests: extend logging test (dropping domains) + + +Conflict:NA +Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/8eddbb9832b9a52a7495cc380e53715d920bb9ea + +--- + glib/tests/logging.c | 40 ++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 40 insertions(+) + +diff --git a/glib/tests/logging.c b/glib/tests/logging.c +index ea9dcb825e..f4c47e16c8 100644 +--- a/glib/tests/logging.c ++++ b/glib/tests/logging.c +@@ -244,6 +244,46 @@ test_default_handler_would_drop (void) + g_assert_false (g_log_writer_default_would_drop (G_LOG_LEVEL_DEBUG, "foo")); + g_assert_false (g_log_writer_default_would_drop (1< +Date: Tue, 14 Nov 2023 11:00:21 +0000 +Subject: [PATCH] gutils: Fix an unlikely minor leak in g_build_user_data_dir() + +A leak can happen if the `data_dir` is the empty string. + +See https://gitlab.gnome.org/GNOME/glib/-/jobs/3294034 + +Conflict:NA +Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/1a979ab4947fc259af01ea65263aaa4d417553fb + +Signed-off-by: Philip Withnall +--- + glib/gutils.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/glib/gutils.c b/glib/gutils.c +index dfe115843e..ffc7d750c7 100644 +--- a/glib/gutils.c ++++ b/glib/gutils.c +@@ -1883,6 +1883,7 @@ g_build_user_data_dir (void) + if (!data_dir || !data_dir[0]) + { + gchar *home_dir = g_build_home_dir (); ++ g_free (data_dir); + data_dir = g_build_filename (home_dir, ".local", "share", NULL); + g_free (home_dir); + } +-- +GitLab \ No newline at end of file diff --git a/glib2.spec b/glib2.spec index 1b63095..9b09b96 100644 --- a/glib2.spec +++ b/glib2.spec @@ -1,6 +1,6 @@ Name: glib2 Version: 2.68.1 -Release: 19 +Release: 20 Summary: The core library that forms the basis for projects such as GTK+ and GNOME License: LGPLv2+ URL: http://www.gtk.org @@ -76,6 +76,10 @@ patch6066: backport-glocalfilemonitor-Avoid-file-monitor-destruction-from-e patch6067: backport-glocalfilemonitor-Skip-event-handling-if-the-source-has-been-destroyed.patch patch6068: backport-tests-Add-a-test-for-GFileMonitor-deadlocks.patch +Patch6069: backport-Make-sure-the-GTask-is-freed-on-a-graceful-disconnect.patch +Patch6070: backport-gmessages-fix-dropping-irrelevant-log-domains.patch +Patch6071: backport-gutils-Fix-an-unlikely-minor-leak-in-g_build_user_data_dir.patch + BuildRequires: chrpath gcc gcc-c++ gettext perl-interpreter BUildRequires: glibc-devel libattr-devel libselinux-devel meson BuildRequires: systemtap-sdt-devel pkgconfig(libelf) pkgconfig(libffi) @@ -240,6 +244,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : %endif %changelog +* Thu Jan 11 2024 hanhuihui - 2.68.1-20 +- fix memory leak and log domains error + * Mon Sep 25 2023 liningjie - 2.68.1-19 - glocalfilemonitor: Avoid file monitor destruction from event thread -- Gitee