From 21893a949519d0d35c83acb96fa8af1840e07779 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 17 Sep 2023 10:53:52 +0200 Subject: [PATCH 1/3] libsigc++3: update to 3.4.0. --- srcpkgs/libsigc++3/template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srcpkgs/libsigc++3/template b/srcpkgs/libsigc++3/template index 664b42fe8e1a1..4c0f466746ba5 100644 --- a/srcpkgs/libsigc++3/template +++ b/srcpkgs/libsigc++3/template @@ -1,6 +1,6 @@ # Template file for 'libsigc++3' pkgname=libsigc++3 -version=3.0.7 +version=3.4.0 revision=1 build_style=meson configure_args="-Dmaintainer-mode=false -Dbuild-documentation=false @@ -11,7 +11,7 @@ license="LGPL-3.0-only" homepage="https://libsigcplusplus.github.io/libsigcplusplus/" changelog="https://github.com/libsigcplusplus/libsigcplusplus/blob/master/NEWS" distfiles="${GNOME_SITE}/libsigc++/${version%.*}/libsigc++-${version}.tar.xz" -checksum=bfbe91c0d094ea6bbc6cbd3909b7d98c6561eea8b6d9c0c25add906a6e83d733 +checksum=02e2630ffb5ce93cd52c38423521dfe7063328863a6e96d41d765a6116b8707e pre_configure() { # build static library as well as shared From e46e0dbba5e20c0e1ccda66b7a79860d4d93dc0e Mon Sep 17 00:00:00 2001 From: John Date: Sun, 17 Sep 2023 10:53:41 +0200 Subject: [PATCH 2/3] glib: update to 2.78.0. --- ...er-Fix-race-between-source-callbacks.patch | 158 ++++++++++++++++++ srcpkgs/glib/template | 6 +- 2 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 srcpkgs/glib/patches/gthreadedresolver-Fix-race-between-source-callbacks.patch diff --git a/srcpkgs/glib/patches/gthreadedresolver-Fix-race-between-source-callbacks.patch b/srcpkgs/glib/patches/gthreadedresolver-Fix-race-between-source-callbacks.patch new file mode 100644 index 0000000000000..17de85b15bdbb --- /dev/null +++ b/srcpkgs/glib/patches/gthreadedresolver-Fix-race-between-source-callbacks.patch @@ -0,0 +1,158 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Philip Withnall +Date: Mon, 11 Sep 2023 16:02:15 +0100 +Subject: [PATCH] gthreadedresolver: Fix race between source callbacks and + finalize +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +I had thought that because `g_source_destroy()` was called for the two +sources (cancel and timeout) in the `GTask` finalize function for a +threaded resolver operation, that it would be fine to use a plain +pointer in the source callbacks to point to the `GTask`. + +That turns out to not be true: because the source callbacks are executed +in the GLib worker thread, and the `GTask` can be finalized in another +thread, it’s possible for a source callback (e.g. `cancelled_cb()`) to +be scheduled in the worker thread, then for the `GTask` to be finalized, +and then the source callback to continue execution and find itself +doing a use-after-free. + +Fix that by using a weak ref to the `GTask` in the source callbacks, +rather than a plain pointer. + +Signed-off-by: Philip Withnall + +Fixes: #3105 +--- + gio/gthreadedresolver.c | 43 +++++++++++++++++++++++++++++++++++------ + 1 file changed, 37 insertions(+), 6 deletions(-) + +diff --git a/gio/gthreadedresolver.c b/gio/gthreadedresolver.c +index 2d94531bfda3..c7a567549f28 100644 +--- a/gio/gthreadedresolver.c ++++ b/gio/gthreadedresolver.c +@@ -1422,85 +1422,116 @@ lookup_records_finish (GResolver *resolver, + static gboolean + timeout_cb (gpointer user_data) + { +- GTask *task = G_TASK (user_data); +- LookupData *data = g_task_get_task_data (task); ++ GWeakRef *weak_task = user_data; ++ GTask *task = NULL; /* (owned) */ ++ LookupData *data; + gboolean should_return; + ++ task = g_weak_ref_get (weak_task); ++ if (task == NULL) ++ return G_SOURCE_REMOVE; ++ ++ data = g_task_get_task_data (task); ++ + g_mutex_lock (&data->lock); + + should_return = g_atomic_int_compare_and_exchange (&data->will_return, NOT_YET, TIMED_OUT); + g_clear_pointer (&data->timeout_source, g_source_unref); + + g_mutex_unlock (&data->lock); + + if (should_return) + g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_TIMED_OUT, + _("Socket I/O timed out")); + + /* Signal completion of the task. */ + g_mutex_lock (&data->lock); + data->has_returned = TRUE; + g_cond_broadcast (&data->cond); + g_mutex_unlock (&data->lock); + ++ g_object_unref (task); ++ + return G_SOURCE_REMOVE; + } + + /* Will be called in the GLib worker thread, so must lock all accesses to shared + * data. */ + static gboolean + cancelled_cb (GCancellable *cancellable, + gpointer user_data) + { +- GTask *task = G_TASK (user_data); +- LookupData *data = g_task_get_task_data (task); ++ GWeakRef *weak_task = user_data; ++ GTask *task = NULL; /* (owned) */ ++ LookupData *data; + gboolean should_return; + ++ task = g_weak_ref_get (weak_task); ++ if (task == NULL) ++ return G_SOURCE_REMOVE; ++ ++ data = g_task_get_task_data (task); ++ + g_mutex_lock (&data->lock); + + g_assert (g_cancellable_is_cancelled (cancellable)); + should_return = g_atomic_int_compare_and_exchange (&data->will_return, NOT_YET, CANCELLED); + g_clear_pointer (&data->cancellable_source, g_source_unref); + + g_mutex_unlock (&data->lock); + + if (should_return) + g_task_return_error_if_cancelled (task); + + /* Signal completion of the task. */ + g_mutex_lock (&data->lock); + data->has_returned = TRUE; + g_cond_broadcast (&data->cond); + g_mutex_unlock (&data->lock); + ++ g_object_unref (task); ++ + return G_SOURCE_REMOVE; + } + ++static void ++weak_ref_clear_and_free (GWeakRef *weak_ref) ++{ ++ g_weak_ref_clear (weak_ref); ++ g_free (weak_ref); ++} ++ + static void + run_task_in_thread_pool_async (GThreadedResolver *self, + GTask *task) + { + LookupData *data = g_task_get_task_data (task); + guint timeout_ms = g_resolver_get_timeout (G_RESOLVER (self)); + GCancellable *cancellable = g_task_get_cancellable (task); + + g_mutex_lock (&data->lock); + + g_thread_pool_push (self->thread_pool, g_object_ref (task), NULL); + + if (timeout_ms != 0) + { ++ GWeakRef *weak_task = g_new0 (GWeakRef, 1); ++ g_weak_ref_set (weak_task, task); ++ + data->timeout_source = g_timeout_source_new (timeout_ms); + g_source_set_static_name (data->timeout_source, "[gio] threaded resolver timeout"); +- g_source_set_callback (data->timeout_source, G_SOURCE_FUNC (timeout_cb), task, NULL); ++ g_source_set_callback (data->timeout_source, G_SOURCE_FUNC (timeout_cb), g_steal_pointer (&weak_task), (GDestroyNotify) weak_ref_clear_and_free); + g_source_attach (data->timeout_source, GLIB_PRIVATE_CALL (g_get_worker_context) ()); + } + + if (cancellable != NULL) + { ++ GWeakRef *weak_task = g_new0 (GWeakRef, 1); ++ g_weak_ref_set (weak_task, task); ++ + data->cancellable_source = g_cancellable_source_new (cancellable); + g_source_set_static_name (data->cancellable_source, "[gio] threaded resolver cancellable"); +- g_source_set_callback (data->cancellable_source, G_SOURCE_FUNC (cancelled_cb), task, NULL); ++ g_source_set_callback (data->cancellable_source, G_SOURCE_FUNC (cancelled_cb), g_steal_pointer (&weak_task), (GDestroyNotify) weak_ref_clear_and_free); + g_source_attach (data->cancellable_source, GLIB_PRIVATE_CALL (g_get_worker_context) ()); + } + diff --git a/srcpkgs/glib/template b/srcpkgs/glib/template index 7362edaaceb0a..71c7c2100a072 100644 --- a/srcpkgs/glib/template +++ b/srcpkgs/glib/template @@ -1,6 +1,6 @@ # Template file for 'glib' pkgname=glib -version=2.76.1 +version=2.78.0 revision=1 build_style=meson # static version is necessary for qemu-user-static; @@ -14,10 +14,10 @@ short_desc="GNU library of C routines" maintainer="Michal Vasilek " license="LGPL-2.1-or-later" homepage="https://wiki.gnome.org/Projects/GLib" -#changelog="https://gitlab.gnome.org/GNOME/glib/raw/glib-2-76/NEWS" +#changelog="https://gitlab.gnome.org/GNOME/glib/raw/glib-2-78/NEWS" changelog="https://gitlab.gnome.org/GNOME/glib/raw/main/NEWS" distfiles="${GNOME_SITE}/glib/${version%.*}/glib-${version}.tar.xz" -checksum=43dc0f6a126958f5b454136c4398eab420249c16171a769784486e25f2fda19f +checksum=44eaab8b720877ce303c5540b657b126f12dc94972d9880b52959f43fb537b30 make_check_pre="dbus-run-session" build_options="gtk_doc" From aaba40c7d52950897a3af6030d1dfcb752824974 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 17 Sep 2023 10:53:45 +0200 Subject: [PATCH 3/3] glibmm2.68: update to 2.78.0. --- srcpkgs/glibmm2.68/template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srcpkgs/glibmm2.68/template b/srcpkgs/glibmm2.68/template index d43e796e9954d..46935cd991732 100644 --- a/srcpkgs/glibmm2.68/template +++ b/srcpkgs/glibmm2.68/template @@ -1,6 +1,6 @@ # Template file for 'glibmm2.68' pkgname=glibmm2.68 -version=2.76.0 +version=2.78.0 revision=1 build_style=meson configure_args="-Dbuild-examples=false" @@ -13,7 +13,7 @@ license="LGPL-2.1-or-later" homepage="https://www.gtkmm.org" changelog="https://gitlab.gnome.org/GNOME/glibmm/-/raw/master/NEWS" distfiles="${GNOME_SITE}/glibmm/${version%.*}/glibmm-${version}.tar.xz" -checksum=8637d80ceabd94fddd6e48970a082a264558d4ab82684e15ffc87e7ef3462ab2 +checksum=5d2e872564996f02a06d8bbac3677e7c394af8b00dd1526aebd47af842a3ef50 glibmm2.68-devel_package() { depends="${makedepends} ${sourcepkg}>=${version}_${revision}"