summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaren Arterius2018-04-19 23:09:50 +0800
committerSaren Arterius2018-04-19 23:09:50 +0800
commitc541ff665a56cdcd09a0c8a7c1ebddc8cdd134f6 (patch)
treed072d8fd76f791f36f3219c3879dab645aabbcb6
downloadaur-c541ff665a56cdcd09a0c8a7c1ebddc8cdd134f6.tar.gz
patched gjs
-rw-r--r--.SRCINFO28
-rw-r--r--PKGBUILD65
-rw-r--r--fix-leaks-lp1672297-1-context-Add-API-to-force-GC-schedule.patch90
-rw-r--r--fix-leaks-lp1672297-2-object-Queue-a-forced-GC-when-toggling-down.patch123
4 files changed, 306 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..0ac33212bfa5
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,28 @@
+pkgbase = gjs-fix-leaks
+ pkgdesc = Javascript Bindings for GNOME
+ pkgver = 1.52.2
+ pkgrel = 1
+ epoch = 1
+ url = https://wiki.gnome.org/Projects/Gjs
+ arch = x86_64
+ license = GPL
+ checkdepends = valgrind
+ makedepends = gobject-introspection
+ makedepends = git
+ makedepends = autoconf-archive
+ makedepends = xorg-server-xvfb
+ depends = cairo
+ depends = gobject-introspection-runtime
+ depends = js52
+ depends = gtk3
+ provides = gjs
+ conflicts = gjs
+ source = git+https://gitlab.gnome.org/GNOME/gjs.git#commit=9a331f9ba850f20734547eb3eaa2f4b1c79bb527
+ source = fix-leaks-lp1672297-1-context-Add-API-to-force-GC-schedule.patch
+ source = fix-leaks-lp1672297-2-object-Queue-a-forced-GC-when-toggling-down.patch
+ sha256sums = SKIP
+ sha256sums = 2f32d58d4408a1c9161a9affd77b062d202217ee645894b00323c0adae77e8f9
+ sha256sums = 0b1757b8175cfc78ec8d64f13730f21bc9b983a84e2081687f2bd0cd48c6bc91
+
+pkgname = gjs-fix-leaks
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..7a95148d461c
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,65 @@
+# $Id$
+# Contributor: Ionut Biru <ibiru@archlinux.org>
+# Packager: Saren Arterius <saren@wtako.net>
+# Patch origin: https://launchpadlibrarian.net/365705963/gjs_1.52.1-1ubuntu1.debdiff
+
+_pkgname=gjs
+pkgname=gjs-fix-leaks
+pkgver=1.52.2
+pkgrel=1
+epoch=1
+pkgdesc="Javascript Bindings for GNOME"
+url="https://wiki.gnome.org/Projects/Gjs"
+arch=(x86_64)
+license=(GPL)
+depends=(cairo gobject-introspection-runtime js52 gtk3)
+makedepends=(gobject-introspection git autoconf-archive xorg-server-xvfb)
+conflicts=(gjs)
+provides=(gjs)
+checkdepends=(valgrind)
+_commit=9a331f9ba850f20734547eb3eaa2f4b1c79bb527 # tags/1.52.2^0
+source=(
+ "git+https://gitlab.gnome.org/GNOME/gjs.git#commit=$_commit"
+ "fix-leaks-lp1672297-1-context-Add-API-to-force-GC-schedule.patch"
+ "fix-leaks-lp1672297-2-object-Queue-a-forced-GC-when-toggling-down.patch")
+sha256sums=(
+ 'SKIP'
+ '2f32d58d4408a1c9161a9affd77b062d202217ee645894b00323c0adae77e8f9'
+ '0b1757b8175cfc78ec8d64f13730f21bc9b983a84e2081687f2bd0cd48c6bc91')
+
+pkgver() {
+ cd $_pkgname
+ git describe --tags | sed 's/-/+/g'
+}
+
+prepare() {
+ cd $_pkgname
+ ## Already in gjs master
+ # patch -Np1 -i ../fix-crashes-lp1763878-revert-575f1e2e077.patch
+ patch -Np1 -i ../fix-leaks-lp1672297-1-context-Add-API-to-force-GC-schedule.patch
+ patch -Np1 -i ../fix-leaks-lp1672297-2-object-Queue-a-forced-GC-when-toggling-down.patch
+ NOCONFIGURE=1 ./autogen.sh
+}
+
+build() {
+ cd $_pkgname
+ ./configure \
+ --prefix=/usr \
+ --libexecdir=/usr/lib \
+ --disable-static \
+ --enable-compile-warnings=yes \
+ --with-xvfb-tests
+ sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
+ make
+}
+
+check() {
+ cd $_pkgname
+ make -j1 check
+}
+
+package() {
+ cd $_pkgname
+ make DESTDIR="$pkgdir" install
+}
+
diff --git a/fix-leaks-lp1672297-1-context-Add-API-to-force-GC-schedule.patch b/fix-leaks-lp1672297-1-context-Add-API-to-force-GC-schedule.patch
new file mode 100644
index 000000000000..84944e6b2f3a
--- /dev/null
+++ b/fix-leaks-lp1672297-1-context-Add-API-to-force-GC-schedule.patch
@@ -0,0 +1,90 @@
+From 33cbbeb11b61a0ffc8ff50e261e5dd33806590f9 Mon Sep 17 00:00:00 2001
+From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
+Date: Fri, 30 Mar 2018 21:37:37 -0300
+Subject: [PATCH 1/2] context: Add API to force GC schedule
+
+There are situations where we cannot run the
+GC right away, but we also cannot ignore the
+need of running it.
+
+For those cases, add a new private function
+that forces GC to happen on idle.
+---
+ gjs/context-private.h | 2 ++
+ gjs/context.cpp | 29 +++++++++++++++++++++++++----
+ 2 files changed, 27 insertions(+), 4 deletions(-)
+
+diff --git a/gjs/context-private.h b/gjs/context-private.h
+index 6dbe669..c45c8d0 100644
+--- a/gjs/context-private.h
++++ b/gjs/context-private.h
+@@ -36,6 +36,8 @@ bool _gjs_context_destroying (GjsContext *js_context);
+
+ void _gjs_context_schedule_gc_if_needed (GjsContext *js_context);
+
++void _gjs_context_schedule_gc (GjsContext *js_context);
++
+ void _gjs_context_exit(GjsContext *js_context,
+ uint8_t exit_code);
+
+diff --git a/gjs/context.cpp b/gjs/context.cpp
+index c509943..77d7eaa 100644
+--- a/gjs/context.cpp
++++ b/gjs/context.cpp
+@@ -90,6 +90,7 @@ struct _GjsContext {
+ uint8_t exit_code;
+
+ guint auto_gc_id;
++ bool force_gc;
+
+ std::array<JS::PersistentRootedId*, GJS_STRING_LAST> const_strings;
+
+@@ -592,21 +593,41 @@ trigger_gc_if_needed (gpointer user_data)
+ {
+ GjsContext *js_context = GJS_CONTEXT(user_data);
+ js_context->auto_gc_id = 0;
+- gjs_gc_if_needed(js_context->context);
++
++ if (js_context->force_gc)
++ JS_GC(js_context->context);
++ else
++ gjs_gc_if_needed(js_context->context);
++
+ return G_SOURCE_REMOVE;
+ }
+
+-void
+-_gjs_context_schedule_gc_if_needed (GjsContext *js_context)
++
++static void
++_gjs_context_schedule_gc_internal (GjsContext *js_context,
++ bool force_gc)
+ {
+ if (js_context->auto_gc_id > 0)
+- return;
++ g_source_remove(js_context->auto_gc_id);
+
++ js_context->force_gc = force_gc;
+ js_context->auto_gc_id = g_idle_add_full(G_PRIORITY_LOW,
+ trigger_gc_if_needed,
+ js_context, NULL);
+ }
+
++void
++_gjs_context_schedule_gc (GjsContext *js_context)
++{
++ _gjs_context_schedule_gc_internal(js_context, true);
++}
++
++void
++_gjs_context_schedule_gc_if_needed (GjsContext *js_context)
++{
++ _gjs_context_schedule_gc_internal(js_context, false);
++}
++
+ void
+ _gjs_context_exit(GjsContext *js_context,
+ uint8_t exit_code)
+--
+2.17.0
+
diff --git a/fix-leaks-lp1672297-2-object-Queue-a-forced-GC-when-toggling-down.patch b/fix-leaks-lp1672297-2-object-Queue-a-forced-GC-when-toggling-down.patch
new file mode 100644
index 000000000000..34f3d3b53cec
--- /dev/null
+++ b/fix-leaks-lp1672297-2-object-Queue-a-forced-GC-when-toggling-down.patch
@@ -0,0 +1,123 @@
+From 3f94b11a943c0e4d29c96930ced238580dc18fc7 Mon Sep 17 00:00:00 2001
+From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
+Date: Wed, 28 Mar 2018 19:21:52 -0300
+Subject: [PATCH 2/2] object: Queue a forced GC when toggling down
+
+During a GC, the collector asks each object which other
+objects that it wants to hold on to so if there's an entire
+section of the heap graph that's not connected to anything
+else, and not reachable from the root set, then it can be
+trashed all at once.
+
+GObjects, however, don't work like that, there's only a
+reference count but no notion of who owns the reference so,
+a JS object that's proxying a GObject is unconditionally held
+alive as long as the GObject has >1 references.
+
+Since we cannot know how many more wrapped GObjects are going
+be marked for garbage collection after the owner is destroyed,
+always queue a garbage collection when a toggle reference goes
+down.
+
+Issue: #140
+---
+ gi/object.cpp | 22 ++++++++++++++++++++++
+ gjs/context-private.h | 2 +-
+ gjs/context.cpp | 14 ++++++++------
+ 3 files changed, 31 insertions(+), 7 deletions(-)
+
+diff --git a/gi/object.cpp b/gi/object.cpp
+index b20d8b9..f9cf3cc 100644
+--- a/gi/object.cpp
++++ b/gi/object.cpp
+@@ -987,8 +987,30 @@ handle_toggle_down(GObject *gobj)
+ * collected by the GC
+ */
+ if (priv->keep_alive.rooted()) {
++ GjsContext *context;
++
+ gjs_debug_lifecycle(GJS_DEBUG_GOBJECT, "Unrooting object");
+ priv->keep_alive.switch_to_unrooted();
++
++ /* During a GC, the collector asks each object which other
++ * objects that it wants to hold on to so if there's an entire
++ * section of the heap graph that's not connected to anything
++ * else, and not reachable from the root set, then it can be
++ * trashed all at once.
++ *
++ * GObjects, however, don't work like that, there's only a
++ * reference count but no notion of who owns the reference so,
++ * a JS object that's proxying a GObject is unconditionally held
++ * alive as long as the GObject has >1 references.
++ *
++ * Since we cannot know how many more wrapped GObjects are going
++ * be marked for garbage collection after the owner is destroyed,
++ * always queue a garbage collection when a toggle reference goes
++ * down.
++ */
++ context = gjs_context_get_current();
++ if (!_gjs_context_destroying(context))
++ _gjs_context_schedule_gc(context);
+ }
+ }
+
+diff --git a/gjs/context-private.h b/gjs/context-private.h
+index c45c8d0..49c0cf9 100644
+--- a/gjs/context-private.h
++++ b/gjs/context-private.h
+@@ -36,7 +36,7 @@ bool _gjs_context_destroying (GjsContext *js_context);
+
+ void _gjs_context_schedule_gc_if_needed (GjsContext *js_context);
+
+-void _gjs_context_schedule_gc (GjsContext *js_context);
++void _gjs_context_schedule_gc(GjsContext *js_context);
+
+ void _gjs_context_exit(GjsContext *js_context,
+ uint8_t exit_code);
+diff --git a/gjs/context.cpp b/gjs/context.cpp
+index 77d7eaa..a2ce34a 100644
+--- a/gjs/context.cpp
++++ b/gjs/context.cpp
+@@ -599,31 +599,33 @@ trigger_gc_if_needed (gpointer user_data)
+ else
+ gjs_gc_if_needed(js_context->context);
+
++ js_context->force_gc = false;
++
+ return G_SOURCE_REMOVE;
+ }
+
+
+ static void
+-_gjs_context_schedule_gc_internal (GjsContext *js_context,
+- bool force_gc)
++_gjs_context_schedule_gc_internal(GjsContext *js_context,
++ bool force_gc)
+ {
+ if (js_context->auto_gc_id > 0)
+- g_source_remove(js_context->auto_gc_id);
++ return;
+
+- js_context->force_gc = force_gc;
++ js_context->force_gc |= force_gc;
+ js_context->auto_gc_id = g_idle_add_full(G_PRIORITY_LOW,
+ trigger_gc_if_needed,
+ js_context, NULL);
+ }
+
+ void
+-_gjs_context_schedule_gc (GjsContext *js_context)
++_gjs_context_schedule_gc(GjsContext *js_context)
+ {
+ _gjs_context_schedule_gc_internal(js_context, true);
+ }
+
+ void
+-_gjs_context_schedule_gc_if_needed (GjsContext *js_context)
++_gjs_context_schedule_gc_if_needed(GjsContext *js_context)
+ {
+ _gjs_context_schedule_gc_internal(js_context, false);
+ }
+--
+2.17.0
+