From 01043f987ad36218e34348fe0a34f05e5440a824 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 18:03:24 +0000 Subject: [PATCH] Potentially fix hang when opening LSP menu (#49046) (cherry-pick to preview) (#49048) Cherry-pick of #49046 to preview ---- It is maybe possible that, if a process's parent dies, the PID can be reused by a different process. This could cause an infinite loop in `is_descendant_of`. To fix this, break out of the loop when a cycle is detected. - [ ] Tests or screenshots needed? - [X] Code Reviewed - [X] Manual QA Release Notes: - N/A --------- Co-authored-by: Eric Holk Co-authored-by: John Tur Co-authored-by: Eric Holk --- crates/language_tools/src/lsp_button.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/language_tools/src/lsp_button.rs b/crates/language_tools/src/lsp_button.rs index 1589947d9e72e11c6be3ff98c1fb65b06260a085..54aae61a696672b5767e05f3cc85aba57d4d3e41 100644 --- a/crates/language_tools/src/lsp_button.rs +++ b/crates/language_tools/src/lsp_button.rs @@ -125,7 +125,11 @@ impl ProcessMemoryCache { fn is_descendant_of(&self, pid: Pid, root_pid: Pid, parent_map: &HashMap) -> bool { let mut current = pid; + let mut visited = HashSet::default(); while current != root_pid { + if !visited.insert(current) { + return false; + } match parent_map.get(¤t) { Some(&parent) => current = parent, None => return false,