unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Christopher Baines <mail@cbaines.net>
Cc: tobias.kortkamp@gmail.com, 58221@debbugs.gnu.org,
	Liliana Marie Prikler <liliana.prikler@gmail.com>
Subject: bug#58221: nautilus: Crashes loading KgxNautilus plugin twice (problems with NAUTILUS_EXTENSION_PATH)
Date: Sun, 20 Nov 2022 18:48:38 +0100	[thread overview]
Message-ID: <87ilj95xft.fsf@gnu.org> (raw)
In-Reply-To: <87o7tft7da.fsf@cbaines.net> (Christopher Baines's message of "Thu, 10 Nov 2022 10:42:25 +0000")

[-- Attachment #1: Type: text/plain, Size: 1417 bytes --]

Hi!

Christopher Baines <mail@cbaines.net> skribis:

> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>
>> Am Samstag, dem 01.10.2022 um 13:29 +0200 schrieb Tobias Kortkamp:
>>> Hi,
>>> 
>>> The problem seems to be that NAUTILUS_EXTENSION_PATH contains the
>>> same path twice and that it tries to load KgxNautilus from each of
>>> the paths:
>>> 
>>> $ echo $NAUTILUS_EXTENSION_PATH
>>> /run/current-system/profile/lib/nautilus/site-
>>> extensions:/run/current-system/profile/lib/nautilus/site-extensions
>>> 
>>> Running Nautilus like this works fine:
>>> 
>>> $ NAUTILUS_EXTENSION_PATH=/run/current-
>>> system/profile/lib/nautilus/site-extensions nautilus
>>
>> I only know of one thing setting this variable, that being nautilus'
>> search-path.  Do you by chance source some profile multiple times?
>
> There might be a related issue where there's duplicates in search paths,
> I've tested in a simple VM and I see the duplication in
> NAUTILUS_EXTENSION_PATH.
>
> Anyway, this probably should be something that doesn't cause nautilus to
> segfault.

Agreed!  I don’t use GNOME and I don’t even know what KgxNautilus is,
but here’s a patch that may fix this by ensuring Nautilus doesn’t load
the same extension twice.

Could you give it a spin and lemme know if it solves this issue?\

That’ll get us closer to a release.  :-)

Thanks,
Ludo’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 4158 bytes --]

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 3d942635a2..78e65d7400 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -9671,7 +9671,9 @@ (define-public nautilus
                                   name "-" version ".tar.xz"))
               (sha256
                (base32
-                "1cncyiyh79w1id6a6s2f0rxmgwl65lp4ml4afa0z35jrnwp2s8cr"))))
+                "1cncyiyh79w1id6a6s2f0rxmgwl65lp4ml4afa0z35jrnwp2s8cr"))
+              (patches
+               (search-patches "nautilus-extension-search-path.patch"))))
     (build-system meson-build-system)
     (arguments
      (list
@@ -9685,27 +9687,6 @@ (define-public nautilus
               (substitute* "test/automated/displayless/meson.build"
                 (("^foreach t: tracker_tests" all)
                  (string-append "tracker_tests = []\n" all)))))
-          (add-after 'unpack 'make-extensible
-            (lambda _
-              (substitute* "src/nautilus-module.c"
-                (("static gboolean initialized = FALSE;" all)
-                 (string-append all "
-const char *extension_path;
-char **extension_dirs, **d;
-")
-                 )
-                (("load_module_dir \\(NAUTILUS_EXTENSIONDIR\\);" all)
-                 (string-append all
-                                "
-extension_path = g_getenv (\"NAUTILUS_EXTENSION_PATH\");
-if (extension_path)
-{
-    extension_dirs = g_strsplit (extension_path, \":\", -1);
-    for (d = extension_dirs; d != NULL && *d != NULL; d++)
-        load_module_dir(*d);
-    g_strfreev(extension_dirs);
-}
-")))))
           (add-after 'unpack 'skip-gtk-update-icon-cache
             ;; Don't create 'icon-theme.cache'.
             (lambda _
diff --git a/gnu/packages/patches/nautilus-extension-search-path.patch b/gnu/packages/patches/nautilus-extension-search-path.patch
new file mode 100644
index 0000000000..aa870d9212
--- /dev/null
+++ b/gnu/packages/patches/nautilus-extension-search-path.patch
@@ -0,0 +1,72 @@
+diff --git a/src/nautilus-module.c b/src/nautilus-module.c
+index bf474bd..42e2a4e 100644
+--- a/src/nautilus-module.c
++++ b/src/nautilus-module.c
+@@ -211,6 +211,10 @@ static void
+ load_module_dir (const char *dirname)
+ {
+     GDir *dir;
++    static GHashTable *loaded = NULL;
++
++    if (loaded == NULL)
++      loaded = g_hash_table_new (g_str_hash, g_str_equal);
+ 
+     dir = g_dir_open (dirname, 0, NULL);
+ 
+@@ -221,15 +225,22 @@ load_module_dir (const char *dirname)
+         while ((name = g_dir_read_name (dir)))
+         {
+             if (g_str_has_suffix (name, "." G_MODULE_SUFFIX))
+-            {
+-                char *filename;
+-
+-                filename = g_build_filename (dirname,
+-                                             name,
+-                                             NULL);
+-                nautilus_module_load_file (filename);
+-                g_free (filename);
+-            }
++	      {
++		/* Make sure each module is loaded only twice or this could
++		   lead to a crash.  Double loading can occur if DIRNAME
++		   occurs more than once in $NAUTILUS_EXTENSION_PATH.  */
++		if (!g_hash_table_contains (loaded, name))
++		  {
++		    char *filename;
++
++		    filename = g_build_filename (dirname,
++						 name,
++						 NULL);
++		    nautilus_module_load_file (filename);
++		    g_hash_table_add (loaded, g_strdup (name));
++		    g_free (filename);
++		  }
++	      }
+         }
+ 
+         g_dir_close (dir);
+@@ -257,10 +268,24 @@ nautilus_module_setup (void)
+ 
+     if (!initialized)
+     {
++        const gchar *extension_path;
+         initialized = TRUE;
+ 
+         load_module_dir (NAUTILUS_EXTENSIONDIR);
+ 
++	/* Load additional modules from the user-provided search path.  */
++	extension_path = g_getenv ("NAUTILUS_EXTENSION_PATH");
++	if (extension_path)
++	  {
++	    char **extension_dirs, **d;
++
++	    extension_dirs = g_strsplit (extension_path, ":", -1);
++	    for (d = extension_dirs; d != NULL && *d != NULL; d++)
++	      load_module_dir (*d);
++
++	    g_strfreev (extension_dirs);
++	  }
++
+         eel_debug_call_at_shutdown (free_module_objects);
+     }
+ }

  reply	other threads:[~2022-11-20 17:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-01 11:29 bug#58221: nautilus: Crashes loading KgxNautilus plugin twice (problems with NAUTILUS_EXTENSION_PATH) Tobias Kortkamp
2022-10-01 12:32 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
2022-10-01 14:40   ` Tobias Kortkamp
2022-10-01 18:14     ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
2022-10-06  7:50       ` Jascha Geerds
2022-10-03  7:46 ` bug#58221: confirmation Attila Lendvai
2022-10-28 13:32 ` bug#58221: (no subject) Alexandre Hannud Abdo
2022-11-09 12:54 ` bug#58221: nautilus: Crashes loading KgxNautilus plugin twice (problems with NAUTILUS_EXTENSION_PATH) Christopher Baines
2022-11-09 19:37 ` Liliana Marie Prikler
2022-11-10 10:42   ` Christopher Baines
2022-11-20 17:48     ` Ludovic Courtès [this message]
2022-11-20 18:02       ` Christopher Baines
2022-11-20 22:23         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ilj95xft.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=58221@debbugs.gnu.org \
    --cc=liliana.prikler@gmail.com \
    --cc=mail@cbaines.net \
    --cc=tobias.kortkamp@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).