Patches to revert MR #585 to work around frequent crash on unlock

This commit is contained in:
Adam Williamson 2021-03-18 18:21:04 -07:00
parent cf41913532
commit 87d72083e6
3 changed files with 172 additions and 1 deletions

View File

@ -0,0 +1,40 @@
From c67ca084d7160f836e7dd7f38ee9941718a1fa82 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Thu, 18 Mar 2021 18:17:54 -0700
Subject: [PATCH 1/2] Revert "tests/Gtk3: Functions that leads running dispose
vfuncs can be safely called"
This reverts commit ffac59100c24ac180065e145b7d04c6af5daf927.
---
installed-tests/js/testGtk3.js | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/installed-tests/js/testGtk3.js b/installed-tests/js/testGtk3.js
index fd0608d1..15187b67 100644
--- a/installed-tests/js/testGtk3.js
+++ b/installed-tests/js/testGtk3.js
@@ -191,21 +191,6 @@ describe('Gtk overrides', function () {
'Gtk overrides avoid crashing and print a stack trace');
});
- it('GTK vfuncs can be explicitly called during disposition', function () {
- let called;
- const GoodLabel = GObject.registerClass(class GoodLabel extends Gtk.Label {
- vfunc_destroy() {
- called = true;
- }
- });
-
- let label = new GoodLabel();
- label.destroy();
- expect(called).toBeTruthy();
- label = null;
- System.gc();
- });
-
it('accepts string in place of GdkAtom', function () {
expect(() => Gtk.Clipboard.get(1)).toThrow();
expect(() => Gtk.Clipboard.get(true)).toThrow();
--
2.30.2

View File

@ -0,0 +1,122 @@
From 457de7f08a2ab07ac7e65a6b27e5c9e09403df16 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Thu, 18 Mar 2021 18:18:00 -0700
Subject: [PATCH 2/2] Revert "object: Do not call any function on disposed
GObject pointers"
This reverts commit d37d6604ca0d50b9be408acd637e8073e30500c7.
---
gi/object.cpp | 15 ++++++---------
gi/toggle.cpp | 16 +++++++++-------
gi/toggle.h | 2 +-
installed-tests/js/testGtk3.js | 7 +++++--
4 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/gi/object.cpp b/gi/object.cpp
index 68410514..c811a065 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1297,9 +1297,7 @@ void
ObjectInstance::release_native_object(void)
{
discard_wrapper();
- if (m_gobj_disposed)
- m_ptr.release();
- else if (m_uses_toggle_ref)
+ if (m_uses_toggle_ref)
g_object_remove_toggle_ref(m_ptr.release(), wrapped_gobj_toggle_notify,
nullptr);
else
@@ -1481,6 +1479,9 @@ ObjectInstance::disassociate_js_gobject(void)
{
bool had_toggle_down, had_toggle_up;
+ if (!m_gobj_disposed)
+ g_object_weak_unref(m_ptr.get(), wrapped_gobj_dispose_notify, this);
+
auto& toggle_queue = ToggleQueue::get_default();
std::tie(had_toggle_down, had_toggle_up) = toggle_queue.cancel(m_ptr.get());
if (had_toggle_down != had_toggle_up) {
@@ -1490,12 +1491,8 @@ ObjectInstance::disassociate_js_gobject(void)
m_ptr.get(), type_name());
}
- if (!m_gobj_disposed) {
- g_object_weak_unref(m_ptr.get(), wrapped_gobj_dispose_notify, this);
-
- /* Fist, remove the wrapper pointer from the wrapped GObject */
- unset_object_qdata();
- }
+ /* Fist, remove the wrapper pointer from the wrapped GObject */
+ unset_object_qdata();
/* Now release all the resources the current wrapper has */
invalidate_closure_list(&m_closures);
diff --git a/gi/toggle.cpp b/gi/toggle.cpp
index 4f7db32f..5f3d4386 100644
--- a/gi/toggle.cpp
+++ b/gi/toggle.cpp
@@ -71,17 +71,19 @@ ToggleQueue::is_queued(GObject *gobj) const
return {has_toggle_down, has_toggle_up};
}
-std::pair<bool, bool> ToggleQueue::cancel(GObject* gobj) {
+std::pair<bool, bool>
+ToggleQueue::cancel(GObject *gobj)
+{
debug("cancel", gobj);
std::lock_guard<std::mutex> hold(lock);
bool had_toggle_down = find_and_erase_operation_locked(gobj, DOWN);
bool had_toggle_up = find_and_erase_operation_locked(gobj, UP);
- gjs_debug_lifecycle(GJS_DEBUG_GOBJECT, "ToggleQueue: %p was %s", gobj,
- had_toggle_down && had_toggle_up
- ? "queued to toggle BOTH"
- : had_toggle_down ? "queued to toggle DOWN"
- : had_toggle_up ? "queued to toggle UP"
- : "not queued");
+ gjs_debug_lifecycle(GJS_DEBUG_GOBJECT, "ToggleQueue: %p (%s) was %s", gobj,
+ G_OBJECT_TYPE_NAME(gobj),
+ had_toggle_down && had_toggle_up ? "queued to toggle BOTH"
+ : had_toggle_down ? "queued to toggle DOWN"
+ : had_toggle_up ? "queued to toggle UP"
+ : "not queued");
return {had_toggle_down, had_toggle_up};
}
diff --git a/gi/toggle.h b/gi/toggle.h
index e77c5419..f7f8eac8 100644
--- a/gi/toggle.h
+++ b/gi/toggle.h
@@ -66,7 +66,7 @@ private:
* are / were queued. is_queued() just checks and does not modify. */
[[nodiscard]] std::pair<bool, bool> is_queued(GObject* gobj) const;
/* Cancels pending toggles and returns whether any were queued. */
- std::pair<bool, bool> cancel(GObject* gobj);
+ std::pair<bool, bool> cancel(GObject *gobj);
/* Pops a toggle from the queue and processes it. Call this if you don't
* want to wait for it to be processed in idle time. Returns false if queue
diff --git a/installed-tests/js/testGtk3.js b/installed-tests/js/testGtk3.js
index 15187b67..f3f6e724 100644
--- a/installed-tests/js/testGtk3.js
+++ b/installed-tests/js/testGtk3.js
@@ -180,11 +180,14 @@ describe('Gtk overrides', function () {
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_CRITICAL,
'*destroy*');
- const BadLabel = GObject.registerClass(class BadLabel extends Gtk.Label {
+ let BadLabel = GObject.registerClass(class BadLabel extends Gtk.Label {
vfunc_destroy() {}
});
- new BadLabel();
+ let w = new Gtk.Window();
+ w.add(new BadLabel());
+
+ w.destroy();
System.gc();
GLib.test_assert_expected_messages_internal('Gjs', 'testGtk3.js', 0,
--
2.30.2

View File

@ -5,7 +5,7 @@
Name: gjs
Version: 1.67.3
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Javascript Bindings for GNOME
# The following files contain code from Mozilla which
@ -16,6 +16,12 @@ License: MIT and (MPLv1.1 or GPLv2+ or LGPLv2+)
URL: https://wiki.gnome.org/Projects/Gjs
Source0: https://download.gnome.org/sources/%{name}/1.67/%{name}-%{version}.tar.xz
# Revert MR #585 to work around frequent crash on unlock:
# https://bugzilla.redhat.com/show_bug.cgi?id=1940171
# https://gitlab.gnome.org/GNOME/gjs/-/issues/387
Patch0001: 0001-Revert-tests-Gtk3-Functions-that-leads-running-dispo.patch
Patch0002: 0002-Revert-object-Do-not-call-any-function-on-disposed-G.patch
BuildRequires: cairo-gobject-devel
BuildRequires: dbus-daemon
BuildRequires: dbus-glib-devel
@ -97,6 +103,9 @@ the functionality of the installed gjs package.
%{_datadir}/installed-tests/
%changelog
* Thu Mar 18 2021 Adam Williamson <awilliam@redhat.com> - 1.67.3-2
- Patches to revert MR #585 to work around frequent crash on unlock
* Mon Mar 15 2021 Kalev Lember <klember@redhat.com> - 1.67.3-1
- Update to 1.67.3