SIGSEGV in xfdesktop_icon_position_configs_assign_monitor() with nested monitor-assignment dialogs during monitor churn

Issue Description

xfdesktop 4.20.2 crashed with SIGSEGV while handling monitor topology changes on X11.

During the same session, I observed multiple xfdesktop monitor-assignment dialogs appearing simultaneously. Attached is a screenshot showing three such dialogs at once:

Screenshot_2026-09-05_20-43-43.png

Each asks whether an existing desktop icon layout should be assigned to "Default Monitor" and offers my HDMI-0 and DP-0 configurations.

My recollection of the eventual crash is that I clicked the window close button ("X") on one of these dialogs. All of the dialogs then disappeared, and I believe xfdesktop crashed at that point. I cannot state with certainty that closing the dialog directly triggered the SIGSEGV.

The screenshot was taken earlier in the same session (approximately 20:43), while the recorded crash occurred at 22:00:27, so the screenshot shows the same repeated-dialog failure state rather than the exact crash moment.

The fully symbolized core dump shows that the crashing thread was processing multiple nested monitor-change paths. create_icon_view() had entered gtk_dialog_run(), which runs a nested GTK/GLib main loop. While that dialog was still running, libxfce4windowing emitted another monitor-removed event. That event re-entered:

handle_monitors_changed()
-> handle_new_mirror_sets()
-> add_monitor_desktop()
-> create_icon_view()
-> gtk_dialog_run()

This happens multiple times in the same stack.

The eventual crash occurs in:

XFW_IS_MONITOR()
-> xfdesktop_icon_position_configs_assign_monitor()

with a non-NULL XfwMonitor * pointer which is apparently no longer a valid monitor object.

This looks consistent with a monitor lifetime / stale-pointer problem caused by monitor removal being processed re-entrantly while the monitor-assignment dialog is running. I cannot prove from the core dump alone that this is specifically a use-after-free.

I have separately observed libxfce4windowing reporting my physical DP-0 monitor as removed and then added again during display re-detection/resume. I reported that monitor behavior under libxfce4windowing issue #64.

That issue may explain why the monitor churn happens, but this report is specifically about the resulting xfdesktop crash.

Steps to Reproduce Issue

I do not currently have a deterministic minimal reproducer for the SIGSEGV, but the sequence observed on my system was:

  1. Run xfdesktop normally on X11 with my display connected as DP-0.
  2. A monitor topology change / display re-detection occurs.
  3. xfdesktop opens a dialog asking whether to assign an existing desktop icon layout to "Default Monitor".
  4. Additional monitor-change events occur while the first dialog is still open.
  5. Multiple identical xfdesktop monitor-assignment dialogs appear simultaneously. I observed three at once.
  6. My recollection is that I clicked the window close button ("X") on one of the dialogs.
  7. All of the dialogs disappeared and xfdesktop crashed with SIGSEGV.

The core dump shows that while an earlier create_icon_view() invocation was blocked in gtk_dialog_run(), further monitor-removed events were being dispatched and re-entering create_icon_view().

Expected Behavior

xfdesktop should safely handle monitor removal/re-addition or other monitor topology changes while the monitor-assignment dialog is open.

Additional monitor events should not cause recursive monitor-assignment dialogs to accumulate, and closing one of those dialogs should not result in xfdesktop dereferencing an invalid monitor object or crashing.

Additional Information

Crash:

Process: /usr/bin/xfdesktop
PID: 6590
Signal: 11 (SIGSEGV)
Timestamp: Sat 2026-09-05 22:00:27 CDT

The most relevant part of the fully symbolized stack trace is:

#0  XFW_IS_MONITOR (ptr=0x7efd500292e0)
    at libxfce4windowing/xfw-monitor.h:87

#1  xfdesktop_icon_position_configs_assign_monitor
    (configs=0x563851fa3830,
     config=0x563851ea0010,
     monitor=0x7efd500292e0)
    at xfdesktop-icon-position-configs.c:1338

#2  create_icon_view(...)
    at xfdesktop-file-icon-manager.c:1476

#3  xfdesktop_file_icon_manager_desktop_added(...)
    at xfdesktop-file-icon-manager.c:1526

#6  add_monitor_desktop(...)
    at xfdesktop-application.c:851

#7  handle_new_mirror_sets(...)

#8  handle_monitors_changed(...)
    at xfdesktop-application.c:978

Below that, the stack contains:

g_signal_emit_by_name(..., "monitor-removed")
_xfw_screen_set_monitors(...)
    at xfw-screen.c:702
refresh_monitors(...)
    at xfw-monitor-x11.c:554
refresh_monitors_idled(...)
    at xfw-monitor-x11.c:564

This monitor refresh is being dispatched from inside:

gtk_dialog_run()
-> create_icon_view()

The backtrace then contains another earlier instance of:

handle_monitors_changed()
-> handle_new_mirror_sets()
-> add_monitor_desktop()
-> create_icon_view()
-> gtk_dialog_run()

followed by another monitor-removed / monitor refresh.

At the crash, create_icon_view() has:

monitor = 0x7efd500292e0

and passes it to:

xfdesktop_icon_position_configs_assign_monitor()

where XFW_IS_MONITOR(monitor) itself segfaults.

I have attached the complete thread apply all bt full output generated from the retained systemd core dump with Arch debuginfod symbols enabled:

xfdesktop-bt-full.txt

Also notice in the screenshot above, the dialogs visibly display the literal markup:

<b>Default Monitor</b>

rather than rendering the text in bold, although that is secondary to the crash itself.

Related monitor behavior has been reported separately as libxfce4windowing issue #64.

I still have the original systemd-coredump entry and can extract additional GDB information if requested.

Environment & Versions

  • OS distribution and version: Manjaro Linux (rolling release)
  • Overall Xfce version: 4.20
  • xfdesktop version (git hash if not a release): 4.20.2-1
  • thunar version (if issue related to file/launcher icons): 4.20.9-1
  • Windowing system (X11/Wayland): X11 / Xorg
  • Compositor and version (if Wayland): N/A
  • GTK Theme: Matcha-dark-pueril
  • Icon Theme: Papirus-Dark-Maia
  • UI Scale Factor: 1

Additional relevant versions:

  • libxfce4windowing: 4.20.7-1
  • xfce4-session: 4.20.4-1
  • xfce4-settings: 4.20.5-1
  • GPU: NVIDIA GeForce RTX 3060
  • NVIDIA driver: 610.57.04 Open