hyprland/ipc: use deleteLater() for workspace and toplevel deletion#499
Open
simaotwx wants to merge 1 commit intoquickshell-mirror:masterfrom
Open
hyprland/ipc: use deleteLater() for workspace and toplevel deletion#499simaotwx wants to merge 1 commit intoquickshell-mirror:masterfrom
simaotwx wants to merge 1 commit intoquickshell-mirror:masterfrom
Conversation
Fix use-after-free crash when rapidly switching workspaces. The crash occurs because QML bindings may still reference workspace/toplevel objects during the same event loop iteration after immediate deletion. Crash stack trace: #0 QV4::QObjectWrapper::wrap (libQt6Qml.so.6) quickshell-mirror#1 QV4::loadProperty (libQt6Qml.so.6) quickshell-mirror#2 QV4::QQmlTypeWrapper::lookupSingletonProperty (libQt6Qml.so.6) Using deleteLater() defers deletion to the next event loop iteration, ensuring all QML bindings have completed their updates first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Quickshell crashes with SIGSEGV when rapidly switching workspaces in Hyprland. The crash occurs because workspace and toplevel objects are deleted immediately while QML bindings may still reference them during the same event loop iteration.
Root Cause
In src/wayland/hyprland/ipc/connection.cpp, workspace and toplevel objects are deleted with delete immediately after being removed from their containers. However, QML property bindings that depend on these objects may not have been re-evaluated yet, causing them to access freed memory when the Qt event loop continues processing.
Solution
Replace delete workspace and delete toplevel with deleteLater() to defer destruction until the next event loop iteration. This ensures all QML bindings have completed their updates before the objects are destroyed.
Stack trace
Testing
Rapidly switch between workspaces using keybindings (e.g., Mod+1, Mod+2 repeatedly). Before this fix, quickshell would crash within a few switches. After the fix, no crashes occur.
Here are some snippets to demonstrate where this issue was coming from: