[Pkg-xfce-commits] r9717 - in /desktop/trunk/thunar/debian: changelog patches/0001-Fix-crash-and-hang-while-renaming.patch patches/0002-Don-t-call-g_object_ref-unref-on-objects-that-are-be.patch patches/series

Yves-Alexis Perez corsac at moszumanska.debian.org
Fri Feb 10 13:55:38 UTC 2017


Author: corsac
Date: Fri Feb 10 13:55:38 2017
New Revision: 9717

URL: http://svn.debian.org/wsvn/pkg-xfce/?sc=1&rev=9717
Log:
* debian/patches:
  - 0001-Fix-crash-and-hang-while-renaming and
  0002-Don-t-call-g_object_ref-unref-on-objects-that-are-be added, new
  attempt at closing the move/rename crash.                   closes: #818484

Added:
    desktop/trunk/thunar/debian/patches/0001-Fix-crash-and-hang-while-renaming.patch
    desktop/trunk/thunar/debian/patches/0002-Don-t-call-g_object_ref-unref-on-objects-that-are-be.patch
Modified:
    desktop/trunk/thunar/debian/changelog
    desktop/trunk/thunar/debian/patches/series

Modified: desktop/trunk/thunar/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/trunk/thunar/debian/changelog?rev=9717&op=diff
==============================================================================
--- desktop/trunk/thunar/debian/changelog	(original)
+++ desktop/trunk/thunar/debian/changelog	Fri Feb 10 13:55:38 2017
@@ -1,3 +1,12 @@
+thunar (1.6.10-5) UNRELEASED; urgency=medium
+
+  * debian/patches:
+    - 0001-Fix-crash-and-hang-while-renaming and
+    0002-Don-t-call-g_object_ref-unref-on-objects-that-are-be added, new
+    attempt at closing the move/rename crash.                   closes: #818484
+
+ -- Yves-Alexis Perez <corsac at debian.org>  Tue, 31 Jan 2017 20:50:55 +0100
+
 thunar (1.6.10-4) unstable; urgency=medium
 
   * debian/patches:

Added: desktop/trunk/thunar/debian/patches/0001-Fix-crash-and-hang-while-renaming.patch
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/trunk/thunar/debian/patches/0001-Fix-crash-and-hang-while-renaming.patch?rev=9717&op=file
==============================================================================
--- desktop/trunk/thunar/debian/patches/0001-Fix-crash-and-hang-while-renaming.patch	(added)
+++ desktop/trunk/thunar/debian/patches/0001-Fix-crash-and-hang-while-renaming.patch	Fri Feb 10 13:55:38 2017
@@ -0,0 +1,102 @@
+From b838a4d250e3283590cabac2ee5947cdf91c8864 Mon Sep 17 00:00:00 2001
+From: pgkos <pgkos.bugzilla at yahoo.com>
+Date: Tue, 31 Jan 2017 19:30:55 +0100
+Subject: [PATCH 1/2] Fix crash and hang while renaming
+
+---
+ thunar/thunar-file.c   | 13 +++++++++++--
+ thunar/thunar-folder.c |  7 +++++++
+ 2 files changed, 18 insertions(+), 2 deletions(-)
+
+--- a/thunar/thunar-file.c
++++ b/thunar/thunar-file.c
+@@ -121,6 +121,7 @@ static gboolean           thunar_file_sa
+ 
+ G_LOCK_DEFINE_STATIC (file_cache_mutex);
+ G_LOCK_DEFINE_STATIC (file_content_type_mutex);
++G_LOCK_DEFINE_STATIC (file_rename_mutex);
+ 
+ 
+ 
+@@ -780,7 +781,9 @@ thunar_file_monitor (GFileMonitor     *m
+       /* the event occurred for the monitored ThunarFile */
+       if (event_type == G_FILE_MONITOR_EVENT_MOVED)
+         {
++          G_LOCK (file_rename_mutex);
+           thunar_file_monitor_moved (file, other_path);
++          G_UNLOCK (file_rename_mutex);
+           return;
+         }
+ 
+@@ -804,6 +807,9 @@ thunar_file_monitor (GFileMonitor     *m
+           if (!other_file)
+               return;
+ 
++
++          G_LOCK (file_rename_mutex);
++
+           /* notify the thumbnail cache that we can now also move the thumbnail */
+           thunar_file_move_thumbnail_cache_file (event_path, other_path);
+ 
+@@ -811,13 +817,14 @@ thunar_file_monitor (GFileMonitor     *m
+           thunar_file_reload_parent (other_file);
+ 
+           g_object_unref (other_file);
++
++          G_UNLOCK (file_rename_mutex);
+         }
+       return;
+     }
+ }
+ 
+ 
+-
+ static void
+ thunar_file_watch_destroyed (gpointer data)
+ {
+@@ -1926,6 +1933,7 @@ thunar_file_rename (ThunarFile   *file,
+     }
+   else
+     {
++      G_LOCK (file_rename_mutex);
+       /* try to rename the file */
+       renamed_file = g_file_set_display_name (file->gfile, name, cancellable, error);
+ 
+@@ -1942,11 +1950,12 @@ thunar_file_rename (ThunarFile   *file,
+               /* emit the file changed signal */
+               thunar_file_changed (file);
+             }
+-
++          G_UNLOCK (file_rename_mutex);
+           return TRUE;
+         }
+       else
+         {
++          G_UNLOCK (file_rename_mutex);
+           return FALSE;
+         }
+     }
+--- a/thunar/thunar-folder.c
++++ b/thunar/thunar-folder.c
+@@ -276,6 +276,9 @@ thunar_folder_finalize (GObject *object)
+ {
+   ThunarFolder *folder = THUNAR_FOLDER (object);
+ 
++  if (folder->corresponding_file)
++    thunar_file_unwatch (folder->corresponding_file);
++
+   /* disconnect from the ThunarFileMonitor instance */
+   g_signal_handlers_disconnect_matched (folder->file_monitor, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, folder);
+   g_object_unref (folder->file_monitor);
+@@ -356,7 +359,11 @@ thunar_folder_set_property (GObject
+   switch (prop_id)
+     {
+     case PROP_CORRESPONDING_FILE:
++      if (folder->corresponding_file)
++        thunar_file_unwatch (folder->corresponding_file);
+       folder->corresponding_file = g_value_dup_object (value);
++      if (folder->corresponding_file)
++        thunar_file_watch (folder->corresponding_file);
+       break;
+ 
+     case PROP_LOADING:

Added: desktop/trunk/thunar/debian/patches/0002-Don-t-call-g_object_ref-unref-on-objects-that-are-be.patch
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/trunk/thunar/debian/patches/0002-Don-t-call-g_object_ref-unref-on-objects-that-are-be.patch?rev=9717&op=file
==============================================================================
--- desktop/trunk/thunar/debian/patches/0002-Don-t-call-g_object_ref-unref-on-objects-that-are-be.patch	(added)
+++ desktop/trunk/thunar/debian/patches/0002-Don-t-call-g_object_ref-unref-on-objects-that-are-be.patch	Fri Feb 10 13:55:38 2017
@@ -0,0 +1,147 @@
+From 35e65ab0ed5675b2dc7b4224b0ad152df3c3e9b0 Mon Sep 17 00:00:00 2001
+From: John Lindgren <john.lindgren at aol.com>
+Date: Fri, 17 Jun 2016 02:50:52 -0400
+Subject: [PATCH 2/2] Don't call g_object_ref/unref on objects that are being
+ finalized.
+
+ThunarFile objects were not being removed from the file_cache until
+thunar_file_finalize().  This leaves a small window of time in which
+another thread might call thunar_file_get(), and fetch the partially
+finalized ThunarFile from the cache.
+
+There are likely some remaining thread-safety issues with ThunarFile,
+due to background jobs making changes to the same objects that are used
+simultaneously in the UI thread.
+---
+ thunar/thunar-file.c | 56 ++++++++++++++++++++++++++++++++++------------------
+ 1 file changed, 37 insertions(+), 19 deletions(-)
+
+diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
+index ccca2c9d..c2a89d8d 100644
+--- a/thunar/thunar-file.c
++++ b/thunar/thunar-file.c
+@@ -221,6 +221,22 @@ G_DEFINE_TYPE_WITH_CODE (ThunarFile, thunar_file, G_TYPE_OBJECT,
+     G_IMPLEMENT_INTERFACE (THUNARX_TYPE_FILE_INFO, thunar_file_info_init))
+ 
+ 
++static GWeakRef*
++weak_ref_new (GObject *obj)
++{
++  GWeakRef *ref;
++  ref = g_slice_new (GWeakRef);
++  g_weak_ref_init (ref, obj);
++  return ref;
++}
++
++static void
++weak_ref_free (GWeakRef *ref)
++{
++  g_weak_ref_clear (ref);
++  g_slice_free (GWeakRef, ref);
++}
++
+ 
+ #ifdef G_ENABLE_DEBUG
+ #ifdef HAVE_ATEXIT
+@@ -236,7 +252,7 @@ thunar_file_atexit_foreach (gpointer key,
+   gchar *uri;
+ 
+   uri = g_file_get_uri (key);
+-  g_print ("--> %s (%u)\n", uri, G_OBJECT (value)->ref_count);
++  g_print ("--> %s\n", uri);
+   if (G_OBJECT (key)->ref_count > 2)
+     g_print ("    GFile (%u)\n", G_OBJECT (key)->ref_count - 2);
+   g_free (uri);
+@@ -278,7 +294,7 @@ thunar_file_cache_dump_foreach (gpointer gfile,
+   gchar *name;
+ 
+   name = g_file_get_parse_name (G_FILE (gfile));
+-  g_print ("    %s (%u)\n", name, G_OBJECT (value)->ref_count);
++  g_print ("    %s\n", name);
+   g_free (name);
+ }
+ 
+@@ -729,7 +745,9 @@ thunar_file_monitor_moved (ThunarFile *file,
+   g_object_unref (previous_file);
+ 
+   /* insert the new entry */
+-  g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
++  g_hash_table_insert (file_cache,
++                       g_object_ref (file->gfile),
++                       weak_ref_new (G_OBJECT (file)));
+ 
+   G_UNLOCK (file_cache_mutex);
+ }
+@@ -1122,11 +1140,9 @@ thunar_file_get_async_finish (GObject      *object,
+ 
+   /* insert the file into the cache */
+   G_LOCK (file_cache_mutex);
+-#ifdef G_ENABLE_DEBUG
+-  /* check if there is no instance created in the meantime */
+-  _thunar_assert (g_hash_table_lookup (file_cache, file->gfile) == NULL);
+-#endif
+-  g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
++  g_hash_table_insert (file_cache,
++                       g_object_ref (file->gfile),
++                       weak_ref_new (G_OBJECT (file)));
+   G_UNLOCK (file_cache_mutex);
+ 
+   /* pass the loaded file and possible errors to the return function */
+@@ -1248,7 +1264,9 @@ thunar_file_get (GFile   *gfile,
+           G_LOCK (file_cache_mutex);
+ 
+           /* insert the file into the cache */
+-          g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
++          g_hash_table_insert (file_cache,
++                               g_object_ref (file->gfile),
++                               weak_ref_new (G_OBJECT (file)));
+ 
+           /* done inserting in the cache */
+           G_UNLOCK (file_cache_mutex);
+@@ -1325,7 +1343,9 @@ thunar_file_get_with_info (GFile     *gfile,
+       G_LOCK (file_cache_mutex);
+ 
+       /* insert the file into the cache */
+-      g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
++      g_hash_table_insert (file_cache,
++                           g_object_ref (file->gfile),
++                           weak_ref_new (G_OBJECT (file)));
+ 
+       /* done inserting in the cache */
+       G_UNLOCK (file_cache_mutex);
+@@ -4096,6 +4116,7 @@ thunar_file_same_filesystem (const ThunarFile *file_a,
+ ThunarFile *
+ thunar_file_cache_lookup (const GFile *file)
+ {
++  GWeakRef   *ref;
+   ThunarFile *cached_file;
+ 
+   _thunar_return_val_if_fail (G_IS_FILE (file), NULL);
+@@ -4108,18 +4129,15 @@ thunar_file_cache_lookup (const GFile *file)
+       file_cache = g_hash_table_new_full (g_file_hash, 
+                                           (GEqualFunc) g_file_equal, 
+                                           (GDestroyNotify) g_object_unref, 
+-                                          NULL);
++                                          (GDestroyNotify) weak_ref_free);
+     }
+ 
+-  cached_file = g_hash_table_lookup (file_cache, file);
++  ref = g_hash_table_lookup (file_cache, file);
+ 
+-  if (cached_file != NULL)
+-    {
+-      /* take a reference to avoid too-early releases outside the
+-       * file_cache_mutex, resuling in destroyed files being used
+-       * in running code */
+-      g_object_ref (cached_file);
+-    }
++  if (ref == NULL)
++    cached_file = NULL;
++  else
++    cached_file = g_weak_ref_get (ref);
+ 
+   G_UNLOCK (file_cache_mutex);
+ 
+-- 
+2.11.0
+

Modified: desktop/trunk/thunar/debian/patches/series
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/trunk/thunar/debian/patches/series?rev=9717&op=diff
==============================================================================
--- desktop/trunk/thunar/debian/patches/series	(original)
+++ desktop/trunk/thunar/debian/patches/series	Fri Feb 10 13:55:38 2017
@@ -1 +1,3 @@
 01_support-non-multiarch-modules.patch
+0001-Fix-crash-and-hang-while-renaming.patch
+0002-Don-t-call-g_object_ref-unref-on-objects-that-are-be.patch




More information about the Pkg-xfce-commits mailing list