xdg-desktop-portal crashed with SIGSEGV

Bug #1691649 reported by none
180
This bug affects 33 people
Affects Status Importance Assigned to Milestone
xdg-desktop-portal (Ubuntu)
Fix Released
High
James Henstridge
Cosmic
Fix Released
High
James Henstridge

Bug Description

Test Case:
1. Boot desktop image to the live session and wait.

https://errors.ubuntu.com/problem/70a7581dd245188e74367f2c31a505b664b972c9

ProblemType: Crash
DistroRelease: Ubuntu 17.10
Package: xdg-desktop-portal 0.6-1
ProcVersionSignature: Ubuntu 4.10.0-21.23-generic 4.10.11
Uname: Linux 4.10.0-21-generic x86_64
ApportVersion: 2.20.5-0ubuntu3
Architecture: amd64
CrashCounter: 1
Date: Wed May 17 13:02:30 2017
ExecutablePath: /usr/lib/xdg-desktop-portal/xdg-desktop-portal
InstallationDate: Installed on 2017-04-11 (37 days ago)
InstallationMedia: Ubuntu 16.10 "Yakkety Yak" - Release amd64 (20161012.2)
ProcCmdline: /usr/lib/xdg-desktop-portal/xdg-desktop-portal
ProcEnviron:
 LANG=zh_CN.UTF-8
 LANGUAGE=zh_CN:zh
 PATH=(custom, no user)
 SHELL=/bin/sh
 XDG_RUNTIME_DIR=<set>
SegvAnalysis:
 Segfault happened at: 0x5593a88781c8: mov 0x8(%rax),%rcx
 PC (0x5593a88781c8) ok
 source "0x8(%rax)" (0x00000008) not located in a known VMA region (needed readable region)!
 destination "%rcx" ok
SegvReason: reading NULL VMA
Signal: 11
SourcePackage: xdg-desktop-portal
StacktraceTop:
 ()
 ()
 () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
 () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
 () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
Title: xdg-desktop-portal crashed with SIGSEGV
UpgradeStatus: Upgraded to artful on 2017-05-17 (1 days ago)
UserGroups:

Revision history for this message
none (misakurarin) wrote :
Revision history for this message
Apport retracing service (apport) wrote :

StacktraceTop:
 export_portal_implementation (connection=0x5593a9126000, skeleton=0x0) at src/xdg-desktop-portal.c:316
 on_bus_acquired (connection=0x5593a9126000, name=<optimized out>, user_data=<optimized out>) at src/xdg-desktop-portal.c:340
 connection_get_cb (source_object=<optimized out>, res=0x5593a9132910, user_data=0x5593a9130d70) at ../../../../gio/gdbusnameowning.c:480
 g_task_return_now (task=0x5593a9132910) at ../../../../gio/gtask.c:1145
 g_task_return (task=0x5593a9132910, type=<optimized out>) at ../../../../gio/gtask.c:1203

Revision history for this message
Apport retracing service (apport) wrote : Stacktrace.txt
Revision history for this message
Apport retracing service (apport) wrote : StacktraceSource.txt
Revision history for this message
Apport retracing service (apport) wrote : ThreadStacktrace.txt
Changed in xdg-desktop-portal (Ubuntu):
importance: Undecided → Medium
tags: removed: need-amd64-retrace
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in xdg-desktop-portal (Ubuntu):
status: New → Confirmed
tags: added: bugpattern-needed
tags: added: bionic
information type: Private → Public
Changed in xdg-desktop-portal (Ubuntu):
importance: Medium → High
description: updated
Will Cooke (willcooke)
Changed in xdg-desktop-portal (Ubuntu):
assignee: nobody → James Henstridge (jamesh)
Revision history for this message
James Henstridge (jamesh) wrote :

So judging by the logs in some of the related error reports, we get the following log messages:

   xdg-desktop-por[3113]: Failed to create file chooser proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gtk: Timeout was reached
   xdg-desktop-por[3113]: g_dbus_interface_skeleton_set_flags: assertion 'G_IS_DBUS_INTERFACE_SKELETON (interface_)' failed
   xdg-desktop-por[3113]: invalid (NULL) pointer instance
   xdg-desktop-por[3113]: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
   xdg-desktop-por[3113]: g_dbus_interface_skeleton_export: assertion 'G_IS_DBUS_INTERFACE_SKELETON (interface_)' failed

This centres around the following code, which is the first portal whose export depends on the presence of a UI implementation:

https://github.com/flatpak/xdg-desktop-portal/blob/1.0.2/src/xdg-desktop-portal.c#L382-L385

  implementation = find_portal_implementation ("org.freedesktop.impl.portal.FileChooser");
  if (implementation != NULL)
    export_portal_implementation (connection,
        file_chooser_create (connection, implementation->dbus_name));

The first line looks up a backend implementation of the FileChooser portal based on the implementations registered in /usr/share/xdg-desktop-portal/portals, and picks xdg-desktop-portal-gtk.

The file_chooser_create method then tries to activate the selected D-Bus name:

https://github.com/flatpak/xdg-desktop-portal/blob/1.0.2/src/file-chooser.c#L578-L589

This corresponds to the first log message, and indicates that starting xdg-desktop-portal-gtk timed out. It returns NULL, and export_portal_implementation() contains no checks for NULL as a second argument leading to the other messages. It ends with a g_return_val_if_fail() check causing g_dbus_interface_skeleton_export() to return FALSE without setting an error. We then get a segfault trying to dereference a NULL GError pointer.

So there's two issues to address:

 1. xdg-desktop-portal-gtk startup is timing out in some instances.
 2. xdg-desktop-portal is not handling this timeout error correctly.

I'll look at addressing (2) since it is the immediate cause of the crash reports, but portals are of limited use if they can't rely on any of the GUI helpers for things like file choosers.

Revision history for this message
James Henstridge (jamesh) wrote :

I've submitted a patch upstream here:

https://github.com/flatpak/xdg-desktop-portal/pull/236

I'll give them a chance to respond and then look at putting together an update to our package.

Revision history for this message
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:
http://iso.qa.ubuntu.com/qatracker/reports/bugs/1691649

tags: added: iso-testing
Revision history for this message
James Henstridge (jamesh) wrote :

The patch was accepted upstream as is, so we can backport it:

https://github.com/flatpak/xdg-desktop-portal/commit/1737e30f5115fea144ab5e3f5f455e40d43dc974

While chatting on IRC, Alex suggested the following set of crash fixes for the xdg-document-portal from 1.0.3 that we may want to consider including:

https://github.com/flatpak/xdg-desktop-portal/commit/7c9f69a20b02b25846f12dd74dc6da94b3faaa05
https://github.com/flatpak/xdg-desktop-portal/commit/b28e903ca3f6d3f8e2dec7af700b4734e418f8c8
https://github.com/flatpak/xdg-desktop-portal/commit/47b2b594075d34f7658cd7c70f3f2518c5c3921e

I'm not sure whether it is worth trying to include them or wait to SRU a later xdg-document-portal post release.

Changed in xdg-desktop-portal (Ubuntu Cosmic):
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package xdg-desktop-portal - 1.0.2-1ubuntu1

---------------
xdg-desktop-portal (1.0.2-1ubuntu1) cosmic; urgency=medium

  * debian/patches/git_timeout_segfault.patch:
    - backport fix from James Henstridge to not segfault when the frontend
      hits a timeout, which seems common on the live session (lp: #1691649)

 -- Sebastien Bacher <email address hidden> Fri, 12 Oct 2018 15:10:27 +0200

Changed in xdg-desktop-portal (Ubuntu Cosmic):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.