From ef1d3ef09658b12101cd32a253d0f4d53ae50f8b Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 20:17:05 -0700 Subject: [PATCH] fix(kde): take the rule locks in one order, so a rule check and a config load cannot deadlock window.rs and static_config.rs locked the float, manage and other rule lists in conflicting orders, which deadlocked KDE tests and could in the daemon. Both now take the locks in one order. Found by test hangs during the merge work. The Windows and macOS trees have the same pattern by reading and were not changed. Verified: the KDE test suite no longer hangs; the VM tier was not re-run. --- komorebi-for-kde/komorebi/src/static_config.rs | 8 +++++--- komorebi-for-kde/komorebi/src/window.rs | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/komorebi-for-kde/komorebi/src/static_config.rs b/komorebi-for-kde/komorebi/src/static_config.rs index e97890e2..3dab9fb3 100644 --- a/komorebi-for-kde/komorebi/src/static_config.rs +++ b/komorebi-for-kde/komorebi/src/static_config.rs @@ -993,16 +993,18 @@ impl StaticConfig { transparency_manager::TRANSPARENCY_ALPHA .store(self.transparency_alpha.unwrap_or(200), Ordering::SeqCst); + // the order every other place takes them in (floating, transparency, ignore, manage, regex): + // a thread that takes two in another order can wait for one that holds what it needs + let mut floating_applications = FLOATING_APPLICATIONS.lock(); + let mut transparency_blacklist = TRANSPARENCY_BLACKLIST.lock(); let mut ignore_identifiers = IGNORE_IDENTIFIERS.lock(); - let mut regex_identifiers = REGEX_IDENTIFIERS.lock(); let mut manage_identifiers = MANAGE_IDENTIFIERS.lock(); + let mut regex_identifiers = REGEX_IDENTIFIERS.lock(); // let mut tray_and_multi_window_identifiers = TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock(); // let mut object_name_change_identifiers = OBJECT_NAME_CHANGE_ON_LAUNCH.lock(); // let mut object_name_change_title_ignore_list = OBJECT_NAME_CHANGE_TITLE_IGNORE_LIST.lock(); // let mut layered_identifiers = LAYERED_WHITELIST.lock(); - let mut transparency_blacklist = TRANSPARENCY_BLACKLIST.lock(); // let mut slow_application_identifiers = SLOW_APPLICATION_IDENTIFIERS.lock(); - let mut floating_applications = FLOATING_APPLICATIONS.lock(); // let mut no_titlebar_applications = NO_TITLEBAR.lock(); if let Some(rules) = &mut self.ignore_rules { diff --git a/komorebi-for-kde/komorebi/src/window.rs b/komorebi-for-kde/komorebi/src/window.rs index 6c3a7f60..0cfbe64f 100644 --- a/komorebi-for-kde/komorebi/src/window.rs +++ b/komorebi-for-kde/komorebi/src/window.rs @@ -529,9 +529,13 @@ fn window_is_eligible( } } - let regex_identifiers = REGEX_IDENTIFIERS.lock(); - + // Every place that holds two of the rule lists takes them in this order: floating, transparency, + // ignore, manage, regex. A thread that takes two in another order can wait for one that holds + // what it needs, and both wait for ever. + let floating_identifiers = FLOATING_APPLICATIONS.lock(); let ignore_identifiers = IGNORE_IDENTIFIERS.lock(); + let manage_identifiers = MANAGE_IDENTIFIERS.lock(); + let regex_identifiers = REGEX_IDENTIFIERS.lock(); let should_ignore = if let Some(rule) = should_act( title, exe_name, @@ -546,7 +550,6 @@ fn window_is_eligible( false }; - let manage_identifiers = MANAGE_IDENTIFIERS.lock(); let managed_override = if let Some(rule) = should_act( title, exe_name, @@ -561,7 +564,6 @@ fn window_is_eligible( false }; - let floating_identifiers = FLOATING_APPLICATIONS.lock(); if let Some(rule) = should_act( title, exe_name,