Skip to content

steamcompmgr: clear destroyed XDG external overlay from connector and global focus - #2487

Merged
matte-schwartz merged 1 commit into
ValveSoftware:masterfrom
sashakosti:fix/layer-shell-external-overlay-disconnect
Oct 23, 2026
Merged

matte-schwartz merged 1 commit into
ValveSoftware:masterfrom
sashakosti:fix/layer-shell-external-overlay-disconnect

Conversation

@sashakosti

Copy link
Copy Markdown

Summary

Fixes a crash (SIGSEGV in window_last_done_commit_index during paint_all) when an XDG-type external overlay client (such as a zwlr_layer_surface_v1 overlay, HUD, or background client) disconnects or is abruptly terminated without an orderly protocol teardown.

Problem

In src/steamcompmgr.cpp:

  1. Commit 038afdc previously added cleanup for pFocus->externalOverlayWindow in destroy_win(), but that function only handles X11/XWayland windows.
  2. For native Wayland XDG/layer-shell surfaces, destruction is processed in steamcompmgr_check_xdg(). When wlserver_xdg_dirty() is true, steamcompmgr_check_xdg() clears stale window references across g_VirtualConnectorFocuses, but omitted externalOverlayWindow.
  3. Additionally, steamcompmgr_xdg_determine_and_apply_focus() never resets g_steamcompmgr_xdg_focus.overlayWindow or externalOverlayWindow to nullptr before iterating active windows, causing stale references to persist if the disconnected window was the only overlay.
  4. During subsequent frames in paint_all() -> paint_window(), externalOverlay is dereferenced after the window has already been deallocated, triggering a crash:
#0  0x00000000004706c7 in window_last_done_commit_index (w=0x2a8cd620) at ../src/steamcompmgr.cpp:1882
1882			if ( w->commit_queue[ i ]->done )
#1  0x000000000047073d in get_window_last_done_commit (w=0x2a8cd620, commit=...) at ../src/steamcompmgr.cpp:1900
#2  0x0000000000473a31 in paint_window (pFocus=..., w=0x2a8cd620, ...) at ../src/steamcompmgr.cpp:2757
#3  0x0000000000476914 in paint_all (pFocus=..., async=false) at ../src/steamcompmgr.cpp:3304

Solution

  • In steamcompmgr_check_xdg():
    • Clear pFocus->externalOverlayWindow if type == steamcompmgr_win_type_t::XDG.
    • Clear g_steamcompmgr_xdg_focus.focusWindow, overlayWindow, and externalOverlayWindow if type == steamcompmgr_win_type_t::XDG.
  • In steamcompmgr_xdg_determine_and_apply_focus():
    • Reset g_steamcompmgr_xdg_focus.overlayWindow and externalOverlayWindow to nullptr prior to scanning active windows.

Tested by spawning a layer-shell overlay client (swaybg) into a running gamescope session presenting vkcube, sending SIGKILL to the overlay client, and verifying that gamescope remains fully stable with no crashes.

Closes #2434

Comment thread src/steamcompmgr.cpp Outdated
… global focus

When an XDG-type external overlay client (such as a zwlr_layer_surface_v1
overlay or HUD) terminates abruptly without orderly cleanup,
steamcompmgr_check_xdg removes the window from wlserver.xdg_wins and clears
stale XDG window references across g_VirtualConnectorFocuses, but skips
externalOverlayWindow. Additionally, steamcompmgr_xdg_determine_and_apply_focus
does not reset g_steamcompmgr_xdg_focus.overlayWindow or externalOverlayWindow
to nullptr before rescanning active windows.

As a result, pFocus->externalOverlayWindow and g_steamcompmgr_xdg_focus
retain dangling pointers to the deallocated window. Subsequent compositor
paint passes (paint_all -> paint_window) dereference the freed window in
window_last_done_commit_index, triggering a SIGSEGV crash.

Clear externalOverlayWindow alongside the other focus windows in
steamcompmgr_check_xdg, and reset overlay pointers in
steamcompmgr_xdg_determine_and_apply_focus and g_steamcompmgr_xdg_focus
when XDG windows are marked dirty.

Closes: ValveSoftware#2434
Co-authored-by: Antigravity <antigravity@google.com>
@sashakosti
sashakosti force-pushed the fix/layer-shell-external-overlay-disconnect branch from 6c9b8a8 to 16f685c Compare October 22, 2026 00:47
@matte-schwartz
matte-schwartz merged commit 765961a into ValveSoftware:master Oct 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segfault when a layer-shell client disconnects without cleanup

2 participants