mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
Potentially fix hang when opening LSP menu (#49046)
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 <eric@zed.dev>
This commit is contained in:
parent
2eb015d10b
commit
bd72484994
1 changed files with 4 additions and 0 deletions
|
|
@ -125,7 +125,11 @@ impl ProcessMemoryCache {
|
|||
|
||||
fn is_descendant_of(&self, pid: Pid, root_pid: Pid, parent_map: &HashMap<Pid, Pid>) -> 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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue