Public bug reported:

xdg-desktop-portal-hyprland 1.3.11 in 26.04 segfaults while exiting: it
disconnects the Wayland display before destroying the proxies, and their
destructors marshal a destroy request into the freed object map. The crash
is on the compositor-gone path, so with Restart=on-failure systemd retries
the portal with no compositor and eventually hits start-limit-hit; screen
sharing and screenshots then stay broken until systemctl --user
reset-failed.

Error tracker:
https://errors.ubuntu.com/problem/e55c50a06765087cacbc01a0d58bfe6a38f1d2e2
Signature:
/usr/libexec/xdg-desktop-portal-hyprland:11:wl_map_insert_at:proxy_destroy:wl_proxy_destroy_caller_locks:wl_proxy_marshal_array_flags:wl_proxy_marshal_flags

83 reports/week on 26.04; 200/200 sampled incidents are 1.3.11-1build2,
200/200 26.04, 200/200 amd64. No Launchpad bug was linked.

Stack:
  wl_map_insert_at
  <- proxy_destroy
  <- wl_proxy_destroy_caller_locks
  <- wl_proxy_marshal_array_flags
  <- wl_proxy_marshal_flags
  <- CCWlOutput::sendRelease
  <- CCWlOutput::~CCWlOutput
  <- SOutput::~SOutput
  <- CPortalManager::~CPortalManager
  <- __run_exit_handlers

The whole stack is exit() after main() returned; this is not a dispatch
race or a double destroy.

== Cause ==

wl_display_disconnect() frees the client object map
(wl_map_release(&display->objects)). Wayland proxies owned by the portal
outlive that call and are destroyed later, during static destruction of
g_pPortalManager, and their destructors marshal a destroy request into the
freed map.

In 1.3.11, src/core/PortalManager.cpp:437-450 calls
wl_display_disconnect(m_sWaylandConnection.display) at :447 and returns.
main() returns, the global unique_ptr<CPortalManager> is destroyed, and
m_vOutputs (declared after m_sWaylandConnection in PortalManager.hpp) is
destroyed first: SOutput::~SOutput -> CCWlOutput::~CCWlOutput ->
sendRelease() -> wl_proxy_marshal_flags(..., WL_MARSHAL_FLAG_DESTROY) ->
wl_map_insert_at() writes into the freed map and faults in
wayland-util.c:290.

It is a write through a freed wl_array, so it only faults when the freed
block was not reused/remapped - hence ~83/week rather than every exit.

== Fix ==

Upstream 0121b2e3f85c7ebf6280173f1054f7e5606262d1 ("core: drop Wayland
proxies before disconnecting the display (#443)", Hadrien Blanc), merged
2026-10-12, first released in 1.5.0 (2026-10-28). Not in 1.3.12 or 1.4.1.

The upstream fix adds CPortalManager::releaseWayland(): it clears
m_vOutputs and resets linuxDmabufFeedback, linuxDmabuf,
hyprlandToplevelMgr, xdgOutputManager, shm and registry, then disconnects
and nulls the display; m_sHelpers.toplevelMapping is reset first.

The attached patch adapts that to the 1.3.11 proxy set (there is no
xdgOutputManager in this version) and includes the toplevelMapping reset.
The 1.3.11 proxy set is complete for this code base.

The upstream fix is incomplete for 1.5.0: #453 reports the same crash
because icc, workspaceSource and m_sHelpers.workspaceTracker are not reset.
That is a separate follow-up for 27.04; the 26.04 backport is complete.

== Verification ==

No compositor and no build dependencies on the preparing host
(sdbus-c++, hyprlang, hyprutils and Qt6 are missing; no sudo), so the
package has not been compiled here. The mechanism was verified with a
libwayland-only reproducer: it connects to a socketpair, takes a real
client id via wl_display_get_registry(), disconnects, then destroys the
registry - the same ordering as the portal teardown. It dies in the
identical frames (SIGSEGV in libwayland-client, wl_proxy_destroy <-
wl_registry_destroy <- main, faulting instruction at wayland-util.c:290);
with the release before disconnect it exits 0. The gdb log is attached.

The patch applies cleanly to the pristine 1.3.11-1build2 tree and every
member it touches exists in PortalManager.hpp at this version.

== SRU ==

Targeted upstream-derived shutdown-order fix for 26.04:
1.3.11-1build2 -> 1.3.11-1ubuntu0.1. Source package and debdiff prepared;
a sponsor build is required because the build dependencies are not
available on the preparing host.

26.10 (1.4.1-1) has the same teardown with an extra CCZxdgOutputV1 proxy
per output and needs a separate backport. 27.04 (1.5.0-1) carries 0121b2e
but not the #453 resets.

Risk: low - shutdown-order-only, no runtime path change, no new build
dependencies.

== Test plan ==

1. On a Hyprland session with 1.3.11-1build2, activate the portal through
   a private D-Bus session and close the bus:
   dbus-run-session -- gdbus call --session --dest
   org.freedesktop.impl.portal.desktop.hyprland --object-path
   /org/freedesktop/portal/desktop --method
   org.freedesktop.DBus.Peer.Ping
   The portal exits via the terminate() tail; expect SIGSEGV in
   wl_map_insert_at.
2. With 1.3.11-1ubuntu0.1, repeat: the portal must exit without a core.
3. Log out of Hyprland with the portal running; no core and no
   start-limit-hit.
4. After release, the error-tracker bucket should fall to zero.

** Affects: xdg-desktop-portal-hyprland (Ubuntu)
     Importance: Medium
         Status: Confirmed

** Affects: xdg-desktop-portal-hyprland (Ubuntu Resolute)
     Importance: Medium
         Status: In Progress

** Affects: xdg-desktop-portal-hyprland (Ubuntu Stonking)
     Importance: Medium
         Status: Confirmed

** Affects: xdg-desktop-portal-hyprland (Ubuntu Tenacious)
     Importance: Medium
         Status: Confirmed


** Tags: desktop-needs-sru resolute stonking tenacious

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2190907

Title:
  xdg-desktop-portal-hyprland 1.3.11: SEGV in wl_map_insert_at on exit

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/xdg-desktop-portal-hyprland/+bug/2190907/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to