[gjs/gnome-3-28] gtype: delete heap wrappers on gtype removal
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/gnome-3-28] gtype: delete heap wrappers on gtype removal
- Date: Sat, 1 Dec 2018 20:59:23 +0000 (UTC)
commit 12172aa369b371e018932ee5e7a5f2270ee0d8d3
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Sat Oct 13 16:52:33 2018 +0200
gtype: delete heap wrappers on gtype removal
(cherry picked from commit 926be39c763a2adddf27a3cdd05dcebfed2e3db3)
gi/gtype.cpp | 15 ++++++++++++---
installed-tests/extra/gjs.supp | 29 -----------------------------
installed-tests/extra/lsan.supp | 3 ---
3 files changed, 12 insertions(+), 35 deletions(-)
---
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index 314f4b28..03920ebf 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -63,13 +63,18 @@ update_gtype_weak_pointers(JSContext *cx,
void *data)
{
for (auto iter = weak_pointer_list.begin(); iter != weak_pointer_list.end(); ) {
- auto heap_wrapper = static_cast<JS::Heap<JSObject *> *>(g_type_get_qdata(*iter,
gjs_get_gtype_wrapper_quark()));
+ GType gtype = *iter;
+ auto heap_wrapper = static_cast<JS::Heap<JSObject *> *>(
+ g_type_get_qdata(gtype, gjs_get_gtype_wrapper_quark()));
JS_UpdateWeakPointerAfterGC(heap_wrapper);
/* No read barriers are needed if the only thing we are doing with the
* pointer is comparing it to nullptr. */
- if (heap_wrapper->unbarrieredGet() == nullptr)
+ if (heap_wrapper->unbarrieredGet() == nullptr) {
+ g_type_set_qdata(gtype, gjs_get_gtype_wrapper_quark(), nullptr);
iter = weak_pointer_list.erase(iter);
+ delete heap_wrapper;
+ }
else
iter++;
}
@@ -95,8 +100,12 @@ gjs_gtype_finalize(JSFreeOp *fop,
if (G_UNLIKELY(gtype == 0))
return;
- weak_pointer_list.erase(gtype);
+ auto heap_wrapper = static_cast<JS::Heap<JSObject*>*>(
+ g_type_get_qdata(gtype, gjs_get_gtype_wrapper_quark()));
+
g_type_set_qdata(gtype, gjs_get_gtype_wrapper_quark(), NULL);
+ weak_pointer_list.erase(gtype);
+ delete heap_wrapper;
}
static bool
diff --git a/installed-tests/extra/gjs.supp b/installed-tests/extra/gjs.supp
index c70baadc..b99eb250 100644
--- a/installed-tests/extra/gjs.supp
+++ b/installed-tests/extra/gjs.supp
@@ -1,35 +1,6 @@
# Valgrind suppressions file for GJS
# This is intended to be used in addition to GLib's glib.supp file.
-# We leak a small wrapper in GJS for each registered GType.
-
-{
- gtype-wrapper-new
- Memcheck:Leak
- match-leak-kinds: definite
- fun:_Znwm
- fun:gjs_gtype_create_gtype_wrapper
-}
-
-{
- gtype-wrapper-qdata
- Memcheck:Leak
- match-leak-kinds: possible
- ...
- fun:type_set_qdata_W
- fun:g_type_set_qdata
- fun:gjs_gtype_create_gtype_wrapper
-}
-
-{
- g_type_register_fundamental never freed
- Memcheck:Leak
- fun:calloc
- ...
- fun:g_type_register_fundamental
- ...
-}
-
# SpiderMonkey leaks
{
diff --git a/installed-tests/extra/lsan.supp b/installed-tests/extra/lsan.supp
index 179eb9c5..3c69851b 100644
--- a/installed-tests/extra/lsan.supp
+++ b/installed-tests/extra/lsan.supp
@@ -1,8 +1,5 @@
# SpiderMonkey leaks a mutex for each GC helper thread.
leak:js::HelperThread::threadLoop
-# We leak a small wrapper in GJS for each registered GType.
-leak:gjs_gtype_create_gtype_wrapper
-
# https://bugs.freedesktop.org/show_bug.cgi?id=105466
leak:libfontconfig.so.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]