Public bug reported:

[ Impact ]

xfce4-notifyd 0.9.7 segfaults on the first notification that is shown or
closed after every monitor has disappeared for a moment and come back:
unplugging a dock, switching all outputs off and on, switching users, some
logouts. The crash brings up the apport "internal error" dialog each time.
The daemon is D-Bus activated again by the next notification, so the visible
damage is the crash dialog and the lost notification.

Cause: the GdkScreen "monitors-changed" handler
(xfce_notify_daemon_screen_changed) reallocates the placement arrays
(reserved_rectangles, monitors_workarea) with g_new0(..., n_monitors).
With zero monitors g_new0() returns NULL. The handler starts with

    if(!xndaemon->monitors_workarea || !xndaemon->reserved_rectangles)
        /* Placement data not initialized, don't update it */
        return;

so from then on every monitors-changed signal returns early and the arrays
stay NULL after the monitors come back. The next call to
xfce_notify_daemon_place_notification_window() or
xfce_notify_daemon_closed() indexes reserved_rectangles[0] and crashes:

    segfault at 0 ... error 4 in xfce4-notifyd
    Segfault happened at: mov (%rax,%rbx,1),%rdi   (rax = reserved_rectangles = 
NULL)

Upstream issue: https://gitlab.xfce.org/apps/xfce4-notifyd/-/issues/176
(same NULL reserved_rectangles, reported on Arch). Upstream fixed it in
master with a redesign (MR !107, "Redesign reserved_rectangles/workarea and
use XfwMonitor"), which is not in any release and needs
libxfce4windowing >= 4.20.6 (26.04 has 4.20.5), so it is not suitable for an
SRU. The attached patch is a minimal fix instead: the handler is only
connected inside xfce_notify_daemon_init_placement_data(), so the guard is
never needed for its stated purpose, and removing it lets the arrays be
reallocated when monitors return.

[ Test Plan ]

Automated, no real monitors needed: reproduce.sh (attached) runs a given
xfce4-notifyd binary in a headless labwc on a private D-Bus session with
throwaway config dirs. It shows a notification, switches the only output
off and on with wlr-randr, then shows another notification.

    sudo apt install labwc wlr-randr libnotify-bin
    ./reproduce.sh /usr/lib/x86_64-linux-gnu/xfce4/notifyd/xfce4-notifyd

Before the fix: "Segmentation fault ... RESULT: notifyd DIED (exit status 139)".
After the fix:  "RESULT: notifyd ALIVE".

Manual, on a Wayland Xfce session with one or more monitors: switch all
outputs off and on again (wlr-randr --output NAME --off / --on, or unplug
and replug the dock), then run notify-send test. Before: xfce4-notifyd
crashes and apport reports it. After: the notification appears and later
notifications keep working.

Both tests were run on 26.04 (0.9.7-2build1 vs. the patched build).

[ Where problems could occur ]

The change only removes an early return from the monitors-changed handler.
The handler now always rebuilds the placement arrays and re-places active
notifications on monitor changes. Before, it skipped that once the arrays
were NULL. The arrays can only be NULL in this handler after a change to
zero monitors, and with zero monitors the free/fill loops run zero times. A
regression would show as notifications placed wrongly or a critical warning
from place_notification_window after hotplug. The X11 _NET_WORKAREA path
keeps its own check and is unchanged.

[ Other Info ]

Debian (unstable and stable) ships the same 0.9.7 code. The patch applies
there unchanged.

Disclosure: this report, the analysis, the patch and the reproducer were
prepared and filed by an AI assistant (Claude Code) on my behalf. The tests
above were run as described, on my 26.04 machine.

** Affects: xfce4-notifyd (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: resolute

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

Title:
  xfce4-notifyd crashed with SIGSEGV after all monitors were removed
  (dock unplug, outputs off, user switch)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/xfce4-notifyd/+bug/2175443/+subscriptions


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

Reply via email to