Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.3.1992 rust-analyzer process spins out of control in macOS VSCode #17378

Closed
ospfranco opened this issue Jun 10, 2024 · 23 comments · Fixed by #17381
Closed

Version 0.3.1992 rust-analyzer process spins out of control in macOS VSCode #17378

ospfranco opened this issue Jun 10, 2024 · 23 comments · Fixed by #17381
Labels
A-perf performance issues Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@ospfranco
Copy link

rust-analyzer version: 0.3.1992

rustc version: rustc 1.78.0 (9b00956e5 2024-04-29)

editor or extension: VSCode

relevant settings: Standard Rustup installation

repository link (if public, optional): n/a

code snippet to reproduce:
n/a

VSCode updated my extensions today and on the latest rust-analyzer version things are spinning out of control:

CleanShot 2024-06-10 at 10 08 43@2x

I've worked around it by downgrading the version on VSCode itself:

CleanShot 2024-06-10 at 10 12 14@2x

@ospfranco ospfranco added the C-bug Category: bug label Jun 10, 2024
@jeromecornuz
Copy link

Same happens on Windows and Linux (rustc 1.78.0 (9b00956e5 2024-04-29))

@TsafrirA
Copy link

I was having a similar issue with Windows, VSCode, WSL Ubuntu.

@lnicola lnicola added A-perf performance issues Broken Window Bugs / technical debt to be addressed immediately labels Jun 10, 2024
@meuschke
Copy link

Same issue here

@lnicola
Copy link
Member

lnicola commented Jun 10, 2024

Can anyone trigger it reliably? A public repository causing the issue or a bisection would be appreciated.

@Veykril
Copy link
Member

Veykril commented Jun 10, 2024

Otherwise capturing backtraces of the running threads would help

@rami3l
Copy link
Member

rami3l commented Jun 10, 2024

Can anyone trigger it reliably? A public repository causing the issue or a bisection would be appreciated.

@lnicola I haven't had the chance to dive into the details yet, but can confirm that rust-lang/rustup is one of the repos that has broken 2024-06-10...

PS: I use :MasonInstall to install an r-a distribution on Neovim, which I believe is just a direct download from your releases page. I just performed a downgrade by executing :MasonInstall rust-analyzer@2024-06-03 and now everything is working alright again.

OS: macOS 14.5.0

@roife
Copy link
Member

roife commented Jun 10, 2024

By git bisect, I find that the problem may originate from 23a5f31.

@wtdcode
Copy link

wtdcode commented Jun 10, 2024

Downgrading saves my day... r-a easily occupies my 7950x in a few minutes with the latest release =(

OS: Ubuntu 2404, bare metal.

@Oakchris1955
Copy link

I have the same problem on Debian Linux. Downgrading to v0.3.1983 fixes the issue.

@roife
Copy link
Member

roife commented Jun 10, 2024

The problem might be in the infinite loop:

while let Some(source_root_id) = par {
par = self.source_root_parent_map.get(&source_root_id).copied();
if let Some((config, _)) = self.ratoml_files.get(&source_root_id) {
if let Some(value) = config.$field.as_ref() {
return value;
}
}
}
.

@roife
Copy link
Member

roife commented Jun 10, 2024

The issue might be in this function: it returns a map {source_root: parent_of_source_root}, but sometimes dir might be equal to parent, which cause the infinite loop we’re seeing above.

Also, the variable i here seems weird, and I’m not sure what it's for. 👀

/// Maps local source roots to their parent source roots by bytewise comparing of root paths .
/// If a `SourceRoot` doesn't have a parent and is local then it is not contained in this mapping but it can be asserted that it is a root `SourceRoot`.
pub fn source_root_parent_map(&self) -> FxHashMap<SourceRootId, SourceRootId> {
let roots = self.fsc.roots();
let mut i = 0;
roots
.iter()
.enumerate()
.filter(|(_, (_, id))| self.local_filesets.contains(id))
.filter_map(|(idx, (root, root_id))| {
// We are interested in parents if they are also local source roots.
// So instead of a non-local parent we may take a local ancestor as a parent to a node.
roots[..idx].iter().find_map(|(root2, root2_id)| {
i += 1;
if self.local_filesets.contains(root2_id) && root.starts_with(root2) {
return Some((root_id, root2_id));
}
None
})
})
.map(|(&child, &parent)| (SourceRootId(child as u32), SourceRootId(parent as u32)))
.collect()
}

@hamsterjiang23
Copy link

同样问题,搞了两小时,换了个旧版本修复了。。无语

@rami3l
Copy link
Member

rami3l commented Jun 10, 2024

Downgrading saves my day... r-a easily occupies my 7950x in a few minutes with the latest release =(

I have the same problem on Debian Linux. Downgrading to v0.3.1983 fixes the issue.

同样问题,搞了两小时,换了个旧版本修复了。。无语

@Veykril @lnicola Can you please pin this issue to increase its visibility first? Many thanks in advance!

@tobico
Copy link

tobico commented Jun 10, 2024

Thanks for reporting, I just ran into this issue on Ubuntu Linux. I'm quite new to Rust and assumed I must have been doing something wrong.

@geeseofbeverlyroad
Copy link

For anyone using VSCode / VSCodium / etc., until this is fixed, having a working rust-analyzer can be achieved by:

  • if opening VSC freezes your machine near-instantly (was the case for me)
    • for good measure, restart, as there can be many rust-analyzer processes still running and consuming most of your CPU
    • manually disable the extension in settings.json
  • open VSC's extensions panel, find rust-analyzer in the list, click the "cog" icon next to it
  • in the menu that appears, select "install another version", then in the list select v0.3.1983
  • enable the extension again

@bors bors closed this as completed in c86d623 Jun 10, 2024
@extrawurst
Copy link

@Veykril thanks for pushing a fix. will there be a hotfix release of this?

@Veykril
Copy link
Member

Veykril commented Jun 10, 2024

There is a new nightly release published now

@huiminghao
Copy link

same here.
win11 WSL2 VSCode

@rami3l
Copy link
Member

rami3l commented Jun 11, 2024

For anyone using VSCode / VSCodium / etc., until this is fixed, having a working rust-analyzer can be achieved by:

  • if opening VSC freezes your machine near-instantly (was the case for me)

    • for good measure, restart, as there can be many rust-analyzer processes still running and consuming most of your CPU
    • manually disable the extension in settings.json
  • open VSC's extensions panel, find rust-analyzer in the list, click the "cog" icon next to it

  • in the menu that appears, select "install another version", then in the list select v0.3.1983

  • enable the extension again

According to @Veykril, a new nightly release is out now including the fix. You can switch to the pre-release version of the VSCode plugin to address this issue. If you're using Neovim/Mason, :MasonInstall rust-analyzer@nightly should be enough.

@TheRealSmeddy
Copy link

For anyone using VSCode / VSCodium / etc., until this is fixed, having a working rust-analyzer can be achieved by:

  • if opening VSC freezes your machine near-instantly (was the case for me)

    • for good measure, restart, as there can be many rust-analyzer processes still running and consuming most of your CPU
    • manually disable the extension in settings.json
  • open VSC's extensions panel, find rust-analyzer in the list, click the "cog" icon next to it

  • in the menu that appears, select "install another version", then in the list select v0.3.1983

  • enable the extension again

According to @Veykril, a new nightly release is out now including the fix. You can switch to the pre-release version of the VSCode plugin to address this issue. If you're using Neovim/Mason, :MasonInstall rust-analyzer@nightly should be enough.

Yep, switching to the pre-release worked for me.

@lnicola
Copy link
Member

lnicola commented Jun 11, 2024

A new stable release is now out (v0.3.1995), fixing this and #17376.

@hackguy25
Copy link

Fix doesn't seem to work on my machine:
Fedora Linux 40 with KDE Plasma x86_64, kernel 6.8.11
VS Code 1.90.0, native install

Versions 0.3.1983 and earlier work correctly, versions 0.3.1992 and 0.3.1995 loop indefinitely.

@lnicola
Copy link
Member

lnicola commented Jun 12, 2024

@hackguy25 might be better to file a new issue. A project link and/or thread backtraces would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-perf performance issues Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.