Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main crashes with segfault on startup #1455

Closed
sophie-h opened this issue Oct 8, 2024 · 8 comments · Fixed by #1461
Closed

main crashes with segfault on startup #1455

sophie-h opened this issue Oct 8, 2024 · 8 comments · Fixed by #1461

Comments

@sophie-h
Copy link
Contributor

sophie-h commented Oct 8, 2024

Operating System

Debian testing

XDG Desktop Portal version

Git

XDG Desktop Portal version (Other)

No response

Desktop Environment

GNOME

Desktop Environment (Other)

No response

Expected Behavior

No segfault

Current Behavior

Okt 08 20:29:24 desktop dbus-daemon[754659]: [session uid=1000 pid=754659] Activating via systemd: service name='org.freedesktop.portal.Desktop' unit='xdg-desktop-portal.service' requested by ':1.205' (uid=1000 pid=763068 comm="xdg-dbus-proxy --args=24")
Okt 08 20:29:24 desktop systemd[2292]: Starting xdg-desktop-portal.service - Portal service...
Okt 08 20:29:24 desktop systemd-coredump[763574]: [🡕] Process 763567 (xdg-desktop-por) of user 1000 dumped core.
                                                  
                                                  Module libblkid.so.1 from deb util-linux-2.40.2-8.amd64
                                                  Module libmount.so.1 from deb util-linux-2.40.2-8.amd64
                                                  Module libatomic.so.1 from deb gcc-14-14.2.0-5.amd64
                                                  Module libsystemd.so.0 from deb systemd-256.6-1.amd64
                                                  Stack trace of thread 763567:
                                                  #0  0x0000556934082d0a portal_impl_supports_iface (xdg-desktop-portal + 0xf6d0a)
                                                  #1  0x00005569340830c6 find_default_implementation_iface (xdg-desktop-portal + 0xf70c6)
                                                  #2  0x000055693408316d find_portal_implementation (xdg-desktop-portal + 0xf716d)
                                                  #3  0x0000556934093f46 on_bus_acquired (xdg-desktop-portal + 0x107f46)
                                                  #4  0x00007fb2cc170205 n/a (libgio-2.0.so.0 + 0x122205)
                                                  #5  0x00007fb2cc107393 n/a (libgio-2.0.so.0 + 0xb9393)
                                                  #6  0x00007fb2cc108033 n/a (libgio-2.0.so.0 + 0xba033)
                                                  #7  0x00007fb2cc15f512 n/a (libgio-2.0.so.0 + 0x111512)
                                                  #8  0x00007fb2cc107393 n/a (libgio-2.0.so.0 + 0xb9393)
                                                  #9  0x00007fb2cc1073cd n/a (libgio-2.0.so.0 + 0xb93cd)
                                                  #10 0x00007fb2cc29d7df n/a (libglib-2.0.so.0 + 0x5a7df)
                                                  #11 0x00007fb2cc29fa17 n/a (libglib-2.0.so.0 + 0x5ca17)
                                                  #12 0x00007fb2cc2a046f g_main_loop_run (libglib-2.0.so.0 + 0x5d46f)
                                                  #13 0x0000556934094919 main (xdg-desktop-portal + 0x108919)
                                                  #14 0x00007fb2cbc30dba __libc_start_call_main (libc.so.6 + 0x29dba)
                                                  #15 0x00007fb2cbc30e75 __libc_start_main_impl (libc.so.6 + 0x29e75)
                                                  #16 0x0000556933fb3221 _start (xdg-desktop-portal + 0x27221)
                                                  
                                                  Stack trace of thread 763570:
                                                  #0  0x00007fb2cbd01266 __GI_ppoll (libc.so.6 + 0xfa266)
                                                  #1  0x00007fb2cc29faec n/a (libglib-2.0.so.0 + 0x5caec)
                                                  #2  0x00007fb2cc2a0180 g_main_context_iteration (libglib-2.0.so.0 + 0x5d180)
                                                  #3  0x00007fb2cc2a01d1 n/a (libglib-2.0.so.0 + 0x5d1d1)
                                                  #4  0x00007fb2cc2d0161 n/a (libglib-2.0.so.0 + 0x8d161)
                                                  #5  0x00007fb2cbc93732 start_thread (libc.so.6 + 0x8c732)
                                                  #6  0x00007fb2cbd0e2b8 __clone3 (libc.so.6 + 0x1072b8)
                                                  
                                                  Stack trace of thread 763571:
                                                  #0  0x00007fb2cbd01266 __GI_ppoll (libc.so.6 + 0xfa266)
                                                  #1  0x00007fb2cc29faec n/a (libglib-2.0.so.0 + 0x5caec)
                                                  #2  0x00007fb2cc2a046f g_main_loop_run (libglib-2.0.so.0 + 0x5d46f)
                                                  #3  0x00007fb2cc175dda n/a (libgio-2.0.so.0 + 0x127dda)
                                                  #4  0x00007fb2cc2d0161 n/a (libglib-2.0.so.0 + 0x8d161)
                                                  #5  0x00007fb2cbc93732 start_thread (libc.so.6 + 0x8c732)
                                                  #6  0x00007fb2cbd0e2b8 __clone3 (libc.so.6 + 0x1072b8)
                                                  
                                                  Stack trace of thread 763569:
                                                  #0  0x00007fb2cbd0c279 syscall (libc.so.6 + 0x105279)
                                                  #1  0x00007fb2cc2cfa84 g_cond_wait (libglib-2.0.so.0 + 0x8ca84)
                                                  #2  0x00007fb2cc2673fb n/a (libglib-2.0.so.0 + 0x243fb)
                                                  #3  0x00007fb2cc2d0402 n/a (libglib-2.0.so.0 + 0x8d402)
                                                  #4  0x00007fb2cc2d0161 n/a (libglib-2.0.so.0 + 0x8d161)
                                                  #5  0x00007fb2cbc93732 start_thread (libc.so.6 + 0x8c732)
                                                  #6  0x00007fb2cbd0e2b8 __clone3 (libc.so.6 + 0x1072b8)
                                                  
                                                  Stack trace of thread 763572:
                                                  #0  0x00007fb2cbd0c279 syscall (libc.so.6 + 0x105279)
                                                  #1  0x00007fb2cc2cff30 g_cond_wait_until (libglib-2.0.so.0 + 0x8cf30)
                                                  #2  0x00007fb2cc2673d3 n/a (libglib-2.0.so.0 + 0x243d3)
                                                  #3  0x00007fb2cc2d078a n/a (libglib-2.0.so.0 + 0x8d78a)
                                                  #4  0x00007fb2cc2d0161 n/a (libglib-2.0.so.0 + 0x8d161)
                                                  #5  0x00007fb2cbc93732 start_thread (libc.so.6 + 0x8c732)
                                                  #6  0x00007fb2cbd0e2b8 __clone3 (libc.so.6 + 0x1072b8)
                                                  ELF object binary architecture: AMD x86-64
Okt 08 20:29:24 desktop systemd[2292]: xdg-desktop-portal.service: Main process exited, code=dumped, status=11/SEGV
Okt 08 20:29:24 desktop systemd[2292]: xdg-desktop-portal.service: Failed with result 'core-dump'.
Okt 08 20:29:24 desktop systemd[2292]: Failed to start xdg-desktop-portal.service - Portal service.

Steps to Reproduce

  1. meson setup builddir
  2. meson install -C builddir
  3. Logout and login
  4. Try to start an app

Anything else we should know?

No response

@sophie-h sophie-h added the bug label Oct 8, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Oct 8, 2024
@swick
Copy link
Collaborator

swick commented Oct 8, 2024

Guess something like this should fix it:

diff --git ./src/portal-impl.c ../src/portal-impl.c
index bf3f2b6..2daa7fc 100644
--- ./src/portal-impl.c
+++ ../src/portal-impl.c
@@ -604,9 +604,16 @@ find_portal_implementation_iface (const PortalInterface *iface)
 
       impl = find_portal_implementation_by_name (portal);
 
+      if (!impl)
+        {
+          g_info ("Requested backend %s does not exist. Skipping...", portal);
+          continue;
+        }
+
       if (!portal_impl_supports_iface (impl, iface->dbus_name))
         {
-          g_info ("Requested backend %s.portal does not support %s. Skipping...", impl->source, iface->dbus_name);
+          g_info ("Requested backend %s.portal does not support %s. Skipping...",
+                  impl->source, iface->dbus_name);
           continue;
         }
 
@@ -637,7 +644,7 @@ find_default_implementation_iface (const char *interface)
 
       impl = find_portal_implementation_by_name (portal);
 
-      if (portal_impl_supports_iface (impl, interface))
+      if (impl && portal_impl_supports_iface (impl, interface))
         return impl;
     }
   return NULL;

@GeorgesStavracas
Copy link
Member

How can we reproduce this crash? What configuration files are you using?

@GeorgesStavracas GeorgesStavracas moved this from Needs Triage to Triaged in Triage Oct 9, 2024
@sophie-h
Copy link
Contributor Author

sophie-h commented Oct 9, 2024

How can we reproduce this crash?

I think it simply happens on every startup of xdg-desktop-portal. What more information can I give there?

What configuration files are you using?

I don't know. How do I check which files I am using?

@GeorgesStavracas
Copy link
Member

I don't know. How do I check which files I am using?

See https://flatpak.github.io/xdg-desktop-portal/docs/portals.conf.html for the list of paths that xdg-desktop-portal searches.

@GeorgesStavracas
Copy link
Member

Also important is which specific portal / backend it was trying to load when it crashed

@sophie-h
Copy link
Contributor Author

sophie-h commented Oct 9, 2024

$ G_MESSAGES_DEBUG=all /usr/local/libexec/xdg-desktop-portal --replace
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/home/herold/.config/xdg-desktop-portal/gnome-portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/home/herold/.config/xdg-desktop-portal/portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/etc/xdg/xdg-desktop-portal/gnome-portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/etc/xdg/xdg-desktop-portal/portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/usr/local/etc/xdg-desktop-portal/gnome-portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/usr/local/etc/xdg-desktop-portal/portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/home/herold/.local/share/xdg-desktop-portal/gnome-portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/home/herold/.local/share/xdg-desktop-portal/portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/usr/share/gnome/xdg-desktop-portal/gnome-portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/usr/share/gnome/xdg-desktop-portal/portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/home/herold/.local/share/flatpak/exports/share/xdg-desktop-portal/gnome-portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/home/herold/.local/share/flatpak/exports/share/xdg-desktop-portal/portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/var/lib/flatpak/exports/share/xdg-desktop-portal/gnome-portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/var/lib/flatpak/exports/share/xdg-desktop-portal/portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/usr/local/share/xdg-desktop-portal/gnome-portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/usr/local/share/xdg-desktop-portal/portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: Looking for portals configuration in '/usr/share/xdg-desktop-portal/gnome-portals.conf'
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.315: load portals from /usr/local/share/xdg-desktop-portal/portals
(/usr/local/libexec/xdg-desktop-portal:844651): GLib-GIO-DEBUG: 16:23:32.315: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ‘gio-vfs’
(/usr/local/libexec/xdg-desktop-portal:844651): GLib-GIO-DEBUG: 16:23:32.316: Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.321: Found 'gnome' in configuration for default
(/usr/local/libexec/xdg-desktop-portal:844651): xdg-desktop-portal-DEBUG: 16:23:32.321: Requested gnome.portal is unrecognized
Segmentation fault (core dumped)
$ cat /usr/share/xdg-desktop-portal/gnome-portals.conf
[preferred]
default=gnome;gtk;
org.freedesktop.impl.portal.Secret=gnome-keyring;
$ cat /usr/share/xdg-desktop-portal/portals/gnome-keyring.portal
[portal]
DBusName=org.freedesktop.secrets
Interfaces=org.freedesktop.impl.portal.Secret
UseIn=gnome
$ cat /usr/share/xdg-desktop-portal/portals/gnome.portal
[portal]
DBusName=org.freedesktop.impl.portal.desktop.gnome
Interfaces=org.freedesktop.impl.portal.Access;org.freedesktop.impl.portal.Account;org.freedesktop.impl.portal.AppChooser;org.freedesktop.impl.portal.Background;org.freedesktop.impl.portal.Clipboard;org.freedesktop.impl.portal.DynamicLauncher;org.freedesktop.impl.portal.FileChooser;org.freedesktop.impl.portal.InputCapture;org.freedesktop.impl.portal.Lockdown;org.freedesktop.impl.portal.Notification;org.freedesktop.impl.portal.Print;org.freedesktop.impl.portal.RemoteDesktop;org.freedesktop.impl.portal.ScreenCast;org.freedesktop.impl.portal.Screenshot;org.freedesktop.impl.portal.Settings;org.freedesktop.impl.portal.Wallpaper;
UseIn=gnome
$ cat /usr/share/xdg-desktop-portal/portals/gtk.portal
[portal]
DBusName=org.freedesktop.impl.portal.desktop.gtk
Interfaces=org.freedesktop.impl.portal.FileChooser;org.freedesktop.impl.portal.AppChooser;org.freedesktop.impl.portal.Print;org.freedesktop.impl.portal.Notification;org.freedesktop.impl.portal.Inhibit;org.freedesktop.impl.portal.Access;org.freedesktop.impl.portal.Account;org.freedesktop.impl.portal.Email;org.freedesktop.impl.portal.DynamicLauncher;org.freedesktop.impl.portal.Lockdown;org.freedesktop.impl.portal.Settings;
UseIn=gnome
$ cat /usr/share/xdg-desktop-portal/portals/gnome-keyring.portal
[portal]
DBusName=org.freedesktop.secrets
Interfaces=org.freedesktop.impl.portal.Secret
UseIn=gnome

@GeorgesStavracas
Copy link
Member

What happens if you run XDG_DESKTOP_PORTAL_DIR=/usr/share/xdg-desktop-portal/portals /usr/local/libexec/xdg-desktop-portal --replace --verbose?

GeorgesStavracas added a commit to GeorgesStavracas/xdg-desktop-portal that referenced this issue Oct 9, 2024
find_portal_implementation_by_name() is nullable, so it's important to
deal with it properly.

Patch originally proposed by @swick.

Closes flatpak#1455
@GeorgesStavracas
Copy link
Member

@sophie-h can you please test #1461 and see if it fixes things for you?

FWIW, #1461 may avoid the crash, but I think there is a problem with your setup. You configured xdg-desktop-portal to use the /usr/local prefix, and it'll try to look at /usr/local/share/xdg-desktop-portal/portals for portal files. Apparently there aren't any portal files there - unless you also go and build and install portal backends with the /usr/local prefix.

github-merge-queue bot pushed a commit that referenced this issue Oct 9, 2024
find_portal_implementation_by_name() is nullable, so it's important to
deal with it properly.

Patch originally proposed by @swick.

Closes #1455
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Triaged
Development

Successfully merging a pull request may close this issue.

3 participants