[mutter/cherry-pick-c7954be5] tests/wayland/test-driver: Unset resource user data on finalize
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/cherry-pick-c7954be5] tests/wayland/test-driver: Unset resource user data on finalize
- Date: Fri, 2 Sep 2022 08:15:02 +0000 (UTC)
commit a36fcf6f70e36edceb8366c7a8096cb90d335020
Author: Jonas Ådahl <jadahl gmail com>
Date: Thu Sep 1 09:37:17 2022 +0200
tests/wayland/test-driver: Unset resource user data on finalize
Client connections may linger after the test driver is teared down;
handle this gracefully by unsetting the user data on the wl_resource,
and make the resource destructor a no-op, instead of where it would
otherwise remove itself from the resource list. This fixes this crash
seen in CI:
Received signal 11 (SIGSEGV)
#0 g_list_remove() at ../glib/glist.c:596
#1 test_driver_destructor() at ../src/tests/meta-wayland-test-driver.c:219
#2 destroy_resource() at ../src/wayland-server.c:730
#3 for_each_helper() at ../src/wayland-util.c:416
#4 wl_map_for_each() at ../src/wayland-util.c:430
#5 wl_client_destroy() at ../src/wayland-server.c:889
#6 wl_display_destroy_clients() at ../src/wayland-server.c:1482
#7 meta_wayland_compositor_prepare_shutdown() at ../src/wayland/meta-wayland.c:441
#8 meta_context_dispose() at ../src/core/meta-context.c:667
#9 g_object_unref() at ../gobject/gobject.c:3863
#9 g_object_unref() at ../gobject/gobject.c:3780
#10 glib_autoptr_clear_GObject() at /usr/include/glib-2.0/gobject/gobject-autocleanups.h:29
#10 glib_autoptr_clear_MetaContext() at ../src/meta/meta-context.h:32
#10 glib_autoptr_cleanup_MetaContext() at ../src/meta/meta-context.h:32
#10 main() at ../src/tests/wayland-unit-tests.c:707
#11 __libc_start_call_main() in /usr/lib64/libc.so.6
#12 __libc_start_main() in /usr/lib64/libc.so.6
#13 _start() in /builds/GNOME/mutter/build/src/tests/mutter-wayland-unit
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2601>
(cherry picked from commit c7954be56edec947f3b649ce88420214bf9d4961)
src/tests/meta-wayland-test-driver.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/tests/meta-wayland-test-driver.c b/src/tests/meta-wayland-test-driver.c
index e8413e0b85..c88f66b7ff 100644
--- a/src/tests/meta-wayland-test-driver.c
+++ b/src/tests/meta-wayland-test-driver.c
@@ -102,7 +102,11 @@ static const struct test_driver_interface meta_test_driver_interface = {
static void
test_driver_destructor (struct wl_resource *resource)
{
- MetaWaylandTestDriver *test_driver = wl_resource_get_user_data (resource);
+ MetaWaylandTestDriver *test_driver;
+
+ test_driver = wl_resource_get_user_data (resource);
+ if (!test_driver)
+ return;
test_driver->resources = g_list_remove (test_driver->resources, resource);
}
@@ -128,6 +132,15 @@ static void
meta_wayland_test_driver_finalize (GObject *object)
{
MetaWaylandTestDriver *test_driver = META_WAYLAND_TEST_DRIVER (object);
+ GList *l;
+
+ for (l = test_driver->resources; l; l = l->next)
+ {
+ struct wl_resource *resource = l->data;
+
+ wl_resource_set_user_data (resource, NULL);
+ }
+ g_clear_list (&test_driver->resources, NULL);
g_clear_pointer (&test_driver->test_driver, wl_global_destroy);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]