[gnome-software/1815-crash-due-to-race-condition-in-gsapp] gs-app: Hold a property lock when reading values in gs_app_to_string_append()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1815-crash-due-to-race-condition-in-gsapp] gs-app: Hold a property lock when reading values in gs_app_to_string_append()
- Date: Wed, 13 Jul 2022 15:15:07 +0000 (UTC)
commit c7ca0c496c099b2ecc409852927f119c25d2139d
Author: Milan Crha <mcrha redhat com>
Date: Wed Jul 13 17:12:56 2022 +0200
gs-app: Hold a property lock when reading values in gs_app_to_string_append()
Holding the lock will make sure that other threads cannot modify
the data being read by the function.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1815
lib/gs-app.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index d7f8be279..a109e109a 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -538,6 +538,7 @@ gs_app_to_string_append (GsApp *app, GString *str)
GList *keys;
const gchar *tmp;
guint i;
+ g_autoptr(GMutexLocker) locker = NULL;
g_autoptr(GsPlugin) management_plugin = NULL;
GsSizeType size_download_dependencies_type, size_installed_dependencies_type;
guint64 size_download_dependencies_bytes, size_installed_dependencies_bytes;
@@ -547,6 +548,8 @@ gs_app_to_string_append (GsApp *app, GString *str)
klass = GS_APP_GET_CLASS (app);
+ locker = g_mutex_locker_new (&priv->mutex);
+
g_string_append_printf (str, " [%p]\n", app);
gs_app_kv_lpad (str, "kind", as_component_kind_to_string (priv->kind));
gs_app_kv_lpad (str, "state", gs_app_state_to_string (priv->state));
@@ -561,7 +564,7 @@ gs_app_to_string_append (GsApp *app, GString *str)
if (priv->id != NULL)
gs_app_kv_lpad (str, "id", priv->id);
if (priv->unique_id != NULL)
- gs_app_kv_lpad (str, "unique-id", gs_app_get_unique_id (app));
+ gs_app_kv_lpad (str, "unique-id", priv->unique_id);
if (priv->scope != AS_COMPONENT_SCOPE_UNKNOWN)
gs_app_kv_lpad (str, "scope", as_component_scope_to_string (priv->scope));
if (priv->bundle_kind != AS_BUNDLE_KIND_UNKNOWN) {
@@ -643,9 +646,11 @@ gs_app_to_string_append (GsApp *app, GString *str)
gs_app_kv_lpad (str, "content-rating",
as_content_rating_get_kind (priv->content_rating));
}
- tmp = gs_app_get_url (app, AS_URL_KIND_HOMEPAGE);
- if (tmp != NULL)
- gs_app_kv_lpad (str, "url{homepage}", tmp);
+ if (priv->urls != NULL) {
+ tmp = g_hash_table_lookup (priv->urls, GINT_TO_POINTER (AS_URL_KIND_HOMEPAGE));
+ if (tmp != NULL)
+ gs_app_kv_lpad (str, "url{homepage}", tmp);
+ }
keys = g_hash_table_get_keys (priv->launchables);
for (GList *l = keys; l != NULL; l = l->next) {
g_autofree gchar *key = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]