Skip to content

core: release client proxies before the display disconnects - #160

Merged
vaxerski merged 1 commit into
hyprwm:mainfrom
UncleJ4ck:fix-teardown-uaf
Nov 13, 2026
Merged

vaxerski merged 1 commit into
hyprwm:mainfrom
UncleJ4ck:fix-teardown-uaf

Conversation

@UncleJ4ck

Copy link
Copy Markdown
Contributor

apps keep their windows, layers and outputs alive across enterLoop() and only drop them after it returns (backend->enterLoop(); return 0; with the window still in scope). by then cleanup() has already disconnected the display, so every proxy they still own gets destroyed against a dead connection. since #120 a lost compositor ends the loop instead of aborting, so this is how toolkit apps go down at session end now.

this releases every window, layer, lock surface, popup and output proxy at the start of cleanup(), while the display is still there. a popup can also be dropped after the backend is gone, so CWaylandPopup::close() checks g_waylandPlatform first.

repro is a nested hyprland: run a client on it and kill -TERM the compositor. on main the client segfaults every time, in ~CWaylandWindow -> close() -> CCXdgToplevel::sendDestroy for a window, ~CCZwlrLayerSurfaceV1 for a layer, ~CCWlOutput for hyprpaper. simpleWindow, simpleLayer, simpleSessionLock and hyprpaper (433a96b) each went from SIGSEGV 3/3 on main to exit 0 3/3 with this. closing the dialog window normally while the compositor stays up exits 0 before and after, and the unit suite passes.

Fixes #134.

apps hold their windows and outputs across enterLoop() and drop them after it
returns, but cleanup() has already disconnected the display by then, so every
proxy they still own gets destroyed on freed memory. since hyprwm#120 a lost
compositor ends the loop instead of aborting, so every toolkit app now crashes
this way at session end (hyprpaper in ~CWaylandOutput, layers, lock surfaces).

drop every window, layer, lock surface, popup and output proxy at the start of
cleanup(), and let a popup be destroyed after the backend is gone.

fixes hyprwm#134
@vaxerski
vaxerski merged commit bf6c2e7 into hyprwm:main Nov 13, 2026
3 checks 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.

Apps built on hyprtoolkit die by signal on compositor disconnect at session end (hyprpaper SIGSEGV, hyprpolkitagent SIGABRT)

2 participants