xfdesktop can crash during startup if the monitor list changes while desktop windows are being created

Description

On Xfce Wayland, xfdesktop sometimes crashes at login, leaving no wallpaper or desktop context menu. Starting xfdesktop again after the monitor layout has settled restores both.

The startup code iterates the borrowed list returned by xfw_screen_get_monitors() and creates desktop windows during that iteration. Creating or showing a window can dispatch Wayland events. If the monitor list changes before the iteration finishes, the loop can continue with an invalid list entry. In the core dump, g_signal_connect_data() was called with a stale monitor pointer from screen_monitor_added().

Reproduction and verification

  • Observed at login: Arch Linux, xfdesktop 4.20.2 with the backdrop connector-key backport, libxfce4windowing 4.20.7, and xfwl4 with a local output-split patch. The crash occurred while the desktop was starting.
  • Controlled test without the split patch: In an isolated KWin Wayland session with three virtual outputs, I removed two outputs during creation of the first desktop window. The unpatched startup code left seven desktop windows instead of one, logged GTK/GLib criticals, and hung on shutdown. This reproduced the faulty handling of a changing monitor list, not the exact login SIGSEGV.

Expected behavior

xfdesktop should finish startup with one desktop window for the remaining output, without crashing or retaining stale windows.

AI disclosure: AI assistance was used for the investigation, test tooling, patch, and report draft.

#403 (moved) seems related but a different crash path