Package: gnome-shell Version: 3.36.3-1 Severity: important Tags: patch User: ubuntu-de...@lists.ubuntu.com Usertags: origin-ubuntu groovy ubuntu-patch
Dear Maintainer, I've noticed gnome-shell-calendar-server process increasing in memory usage to the point of 10s of GBs, repeatedly, over the course of a day or two. So I dove into the code, profiled with valgrind, and identified a few possible memory leaks. I made some fixes (and after a few round trips), was able to verify that the process no longer grows in memory usage, even after a few days. I submitted a Merge Request to Gnome (https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1335), which they don't need, as they chose to backport a larger set of changes that also address the leaks. However, since those changes will take a while to be released and make it downstream, I thought I'd submit my fix for now. For reference, the Ubuntu bug is tracked here: https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/1885346 Thanks for considering the patch. -- System Information: Debian Release: bullseye/sid APT prefers focal-updates APT policy: (500, 'focal-updates'), (500, 'focal-security'), (500, 'focal-proposed'), (500, 'focal'), (100, 'focal-backports') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 5.4.0-40-generic (SMP w/4 CPU cores) Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages gnome-settings-daemon depends on: ii gnome-settings-daemon-common 3.36.1-0ubuntu1 ii gsettings-desktop-schemas 3.36.0-1ubuntu1 ii libaccountsservice0 0.6.55-0ubuntu12~20.04.1 ii libasound2 1.2.2-2.1ubuntu1 ii libc6 2.31-0ubuntu9 ii libcairo2 1.16.0-4ubuntu1 ii libcanberra-gtk3-0 0.30-7ubuntu1 ii libcanberra0 0.30-7ubuntu1 ii libcolord2 1.4.4-2 ii libcups2 2.3.1-9ubuntu1.1 ii libfontconfig1 2.13.1-2ubuntu3 ii libgcr-base-3-1 3.36.0-2build1 ii libgdk-pixbuf2.0-0 2.40.0+dfsg-3 ii libgeoclue-2-0 2.5.6-0ubuntu1 ii libgeocode-glib0 3.26.2-2 ii libglib2.0-0 2.64.2-1~fakesync1 ii libgnome-desktop-3-19 3.36.2-0ubuntu2 ii libgtk-3-0 3.24.20-0ubuntu1 ii libgudev-1.0-0 1:233-1 ii libgweather-3-16 3.36.0-1 ii liblcms2-2 2.9-4 ii libmm-glib0 1.12.8-1 ii libnm0 1.22.10-1ubuntu2.1 ii libnotify4 0.7.9-1ubuntu2 ii libnspr4 2:4.25-1 ii libnss3 2:3.49.1-1ubuntu1.1 ii libpam-systemd [logind] 245.4-4ubuntu3.1 ii libpango-1.0-0 1.44.7-2ubuntu4 ii libpangocairo-1.0-0 1.44.7-2ubuntu4 ii libpolkit-gobject-1-0 0.105-26ubuntu1 ii libpulse-mainloop-glib0 1:13.99.1-1ubuntu3.3 ii libpulse0 1:13.99.1-1ubuntu3.3 ii libupower-glib3 0.99.11-1build2 ii libwacom2 1.3-2ubuntu1 ii libwayland-client0 1.18.0-1 ii libx11-6 2:1.6.9-2ubuntu1 ii libxext6 2:1.3.4-0ubuntu1 ii libxi6 2:1.7.10-0ubuntu1 ii x11-xserver-utils 7.7+8 Versions of packages gnome-settings-daemon recommends: ii iio-sensor-proxy 2.8-1 ii pulseaudio 1:13.99.1-1ubuntu3.3 Versions of packages gnome-settings-daemon suggests: pn usbguard <none> Versions of packages libgjs0g depends on: ii libc6 2.31-0ubuntu9 ii libcairo-gobject2 1.16.0-4ubuntu1 ii libcairo2 1.16.0-4ubuntu1 ii libffi7 3.3-4 ii libgcc-s1 10-20200411-0ubuntu1 ii libgirepository-1.0-1 1.64.1-1~ubuntu20.04.1 ii libglib2.0-0 2.64.2-1~fakesync1 ii libmozjs-68-0 68.6.0-1ubuntu1 ii libreadline8 8.0-4 ii libstdc++6 10-20200411-0ubuntu1 ii libx11-6 2:1.6.9-2ubuntu1 Versions of packages gnome-shell is related to: ii libegl-mesa0 [libegl-vendor] 20.0.8-0ubuntu1~20.04.1 ii libgl1-mesa-dri 20.0.8-0ubuntu1~20.04.1 ii libglx-mesa0 [libglx-vendor] 20.0.8-0ubuntu1~20.04.1
diff -Nru gnome-shell-3.36.3/debian/control gnome-shell-3.36.3/debian/control --- gnome-shell-3.36.3/debian/control 2020-06-05 14:20:50.000000000 -0400 +++ gnome-shell-3.36.3/debian/control 2020-07-11 00:44:51.000000000 -0400 @@ -5,8 +5,7 @@ Source: gnome-shell Section: gnome Priority: optional -Maintainer: Ubuntu Developers <ubuntu-devel-disc...@lists.ubuntu.com> -XSBC-Original-Maintainer: Debian GNOME Maintainers <pkg-gnome-maintain...@lists.alioth.debian.org> +Maintainer: Debian GNOME Maintainers <pkg-gnome-maintain...@lists.alioth.debian.org> Uploaders: Iain Lane <la...@debian.org>, Jeremy Bicha <jbi...@debian.org> Build-Depends: appstream, asciidoc-base, diff -Nru gnome-shell-3.36.3/debian/control.in gnome-shell-3.36.3/debian/control.in --- gnome-shell-3.36.3/debian/control.in 2020-06-05 14:20:50.000000000 -0400 +++ gnome-shell-3.36.3/debian/control.in 2020-07-11 00:44:51.000000000 -0400 @@ -1,8 +1,7 @@ Source: gnome-shell Section: gnome Priority: optional -Maintainer: Ubuntu Developers <ubuntu-devel-disc...@lists.ubuntu.com> -XSBC-Original-Maintainer: Debian GNOME Maintainers <pkg-gnome-maintain...@lists.alioth.debian.org> +Maintainer: Debian GNOME Maintainers <pkg-gnome-maintain...@lists.alioth.debian.org> Uploaders: @GNOME_TEAM@ Build-Depends: appstream, asciidoc-base, diff -Nru gnome-shell-3.36.3/debian/patches/fix-memleaks-in-calendar-server.patch gnome-shell-3.36.3/debian/patches/fix-memleaks-in-calendar-server.patch --- gnome-shell-3.36.3/debian/patches/fix-memleaks-in-calendar-server.patch 1969-12-31 19:00:00.000000000 -0500 +++ gnome-shell-3.36.3/debian/patches/fix-memleaks-in-calendar-server.patch 2020-07-11 00:44:34.000000000 -0400 @@ -0,0 +1,93 @@ +Description: Fix a few memory leaks in calendar-server + +* Free allocation of calendar appointments (not just their contents) +* Properly pass GVariantBuilders to variant funcs +* Use NULLs where builders aren't populated, to avoid allocations +* Use stack allocated builders to further reduce allocs + +Note for package maintainers: the leaks this patch fixes have been +addressed in Gnome's repo via a much larger backported changeset that I +was unable to build & verify on my own. Once they release those changes, +this patch will no longer be necessary. + +Fixes #1885346 + +Author: Heewa Barfchin <heew...@gmail.com> +Origin: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1335/diffs?commit_id=6ea617895e91f929d693a546c462fa12e030fa0d +Bug: https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/1885346 +Bug-GNOME: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1335 +Last-Update: 2020-07-10 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: gnome-shell-3.36.3/src/calendar-server/gnome-shell-calendar-server.c +=================================================================== +--- gnome-shell-3.36.3.orig/src/calendar-server/gnome-shell-calendar-server.c ++++ gnome-shell-3.36.3/src/calendar-server/gnome-shell-calendar-server.c +@@ -404,6 +404,8 @@ calendar_appointment_free (CalendarAppoi + + appointment->start_time = 0; + appointment->is_all_day = FALSE; ++ ++ g_free (appointment); + } + + static void +@@ -857,18 +859,16 @@ handle_method_call (GDBusConnection + window_changed = FALSE; + if (!(app->until == until && app->since == since)) + { +- GVariantBuilder *builder; +- GVariantBuilder *invalidated_builder; ++ GVariantBuilder builder; + + app->until = until; + app->since = since; + window_changed = TRUE; + +- builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}")); +- invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); +- g_variant_builder_add (builder, "{sv}", ++ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); ++ g_variant_builder_add (&builder, "{sv}", + "Until", g_variant_new_int64 (app->until)); +- g_variant_builder_add (builder, "{sv}", ++ g_variant_builder_add (&builder, "{sv}", + "Since", g_variant_new_int64 (app->since)); + g_dbus_connection_emit_signal (app->connection, + NULL, /* destination_bus_name */ +@@ -877,8 +877,8 @@ handle_method_call (GDBusConnection + "PropertiesChanged", + g_variant_new ("(sa{sv}as)", + "org.gnome.Shell.CalendarServer", +- builder, +- invalidated_builder), ++ &builder, ++ NULL), + NULL); /* GError** */ + } + +@@ -895,7 +895,6 @@ handle_method_call (GDBusConnection + g_hash_table_iter_init (&hash_iter, app->appointments); + while (g_hash_table_iter_next (&hash_iter, NULL, (gpointer) &a)) + { +- GVariantBuilder extras_builder; + GSList *l; + + for (l = a->occurrences; l; l = l->next) +@@ -919,7 +918,6 @@ handle_method_call (GDBusConnection + a->uid, + o->rid ? o->rid : ""); + +- g_variant_builder_init (&extras_builder, G_VARIANT_TYPE ("a{sv}")); + g_variant_builder_add (&builder, + "(sssbxxa{sv})", + id, +@@ -928,7 +926,7 @@ handle_method_call (GDBusConnection + (gboolean) a->is_all_day, + (gint64) start_time, + (gint64) end_time, +- extras_builder); ++ NULL); + g_free (id); + } + } diff -Nru gnome-shell-3.36.3/debian/patches/series gnome-shell-3.36.3/debian/patches/series --- gnome-shell-3.36.3/debian/patches/series 2020-06-05 14:20:50.000000000 -0400 +++ gnome-shell-3.36.3/debian/patches/series 2020-07-11 00:43:35.000000000 -0400 @@ -16,3 +16,4 @@ ubuntu/resolve_alternate_theme_path.patch ubuntu/secure_mode_extension.patch ubuntu/keep-ubuntu-logo-bright-lp1867133-v1.patch +fix-memleaks-in-calendar-server.patch