python3-pyobject: Add patch to fix resource leak that causes mem leak & OOM
PATCH 1/1 python3-pyobject: Add patch to fix resource leak that causes mem leak & OOM
From: Geoff Parker <[email protected]>
Memory leak and OOM in our code involving dbus was traced to a resource leak in python3-gobject above v3.24.1 noted in these links.
https://github.com/LEW21/pydbus/issues/83
https://gitlab.gnome.org/GNOME/pygobject/-/issues/307
This patch fixed the leak for us.
This issue has existed at least 3 years. The author of this patch opened an issue 2 years ago on the upstream pygobject gnome project and submitted this patch a year ago. The maintainer seems unresponsive, since the last upstream change to the affected file was on 2020-04-15.
Signed-off-by Geoff Parker <[email protected]>
--- ...d-to-fix-the-invocation-object-leaks.patch | 40 +++++++++++++++++++ .../python/python3-pygobject_3.42.0.bb | 1 + 2 files changed, 41 insertions(+) create mode 100644 meta/recipes-devtools/python/python3-pygobject/0002-workaround-to-fix-the-invocation-object-leaks.patch
meta/recipes-devtools/python/python3-pygobject/0002-workaround-to-fix-the-invocation-object-leaks.patch new file +40 -0
@@ -0,0 +1,40 @@ +From 3da1eaaa891b7dfdba57b16c079ff8c6100ebb45 Mon Sep 17 00:00:00 2001 +From: Frederic Martinsons <[email protected]> +Date: Fri, 15 Jan 2021 07:24:37 +0100 +Subject: [PATCH] Workaround to fix the invocation object leaks + +See https://gitlab.gnome.org/GNOME/pygobject/-/issues/307 for description + +Signed-off-by: Frederic Martinsons <[email protected]> +--- + gi/pygi-object.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/gi/pygi-object.c b/gi/pygi-object.c +index 00b36c1b..5ca45975 100644 +--- a/gi/pygi-object.c ++++ b/gi/pygi-object.c +@@ -213,8 +213,18 @@ _pygi_marshal_cleanup_from_py_interface_object (PyGIInvokeState *state, + /* If we processed the parameter but fail before invoking the method, + we need to remove the ref we added */ + if (was_processed && state->failed && data != NULL && +- arg_cache->transfer == GI_TRANSFER_EVERYTHING) ++ arg_cache->transfer == GI_TRANSFER_EVERYTHING) { + g_object_unref (G_OBJECT(data)); ++ return; ++ } ++ ++ /* BAD hack to solve https://gitlab.gnome.org/GNOME/pygobject/-/issues/307 */ ++ if (was_processed && data != NULL && arg_cache->transfer == GI_TRANSFER_EVERYTHING) { ++ GObject* obj = G_OBJECT(data); ++ if (!g_strcmp0(G_OBJECT_TYPE_NAME(obj), "GDBusMethodInvocation") && obj->ref_count > 1) { ++ g_object_unref (G_OBJECT(data)); ++ } ++ } + } + + +-- +2.25.1 + +
meta/recipes-devtools/python/python3-pygobject_3.42.0.bb +1 -0
@@ -17,6 +17,7 @@ SRCNAME="pygobject" SRC_URI = " \ http://ftp.gnome.org/pub/GNOME/sources/${SRCNAME}/${@gnome_verdir("${PV}")}/${SRCNAME}-${PV}.tar.xz \ file://0001-Do-not-build-tests.patch \ + file://0002-workaround-to-fix-the-invocation-object-leaks.patch \ " SRC_URI[sha256sum] = "9b12616e32cfc792f9dc841d9c472a41a35b85ba67d3a6eb427e307a6fe4367b"
Signature · 1 line
2.30.2