rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.15k stars 1.58k forks source link

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

Closed ospfranco closed 3 months ago

ospfranco commented 3 months ago

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

jeromecornuz commented 3 months ago

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

TsafrirA commented 3 months ago

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

meuschke commented 3 months ago

Same issue here

lnicola commented 3 months ago

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

Veykril commented 3 months ago

Otherwise capturing backtraces of the running threads would help

rami3l commented 3 months ago

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 commented 3 months ago

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

wtdcode commented 3 months ago

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

OS: Ubuntu 2404, bare metal.

Oakchris1955 commented 3 months ago

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

roife commented 3 months ago

The problem might be in the infinite loop: https://github.com/rust-lang/rust-analyzer/blob/14a1f4530ca7d63f0c4137c9b3daa5e15c524b9c/crates/rust-analyzer/src/config.rs#L2562-L2569.

roife commented 3 months ago

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. 👀

https://github.com/rust-lang/rust-analyzer/blob/14a1f4530ca7d63f0c4137c9b3daa5e15c524b9c/crates/load-cargo/src/lib.rs#L284-L306

hamsterjiang23 commented 3 months ago

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

rami3l commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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

extrawurst commented 3 months ago

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

Veykril commented 3 months ago

There is a new nightly release published now

huiminghao commented 3 months ago

same here. win11 WSL2 VSCode

rami3l commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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

hackguy25 commented 3 months ago

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 commented 3 months ago

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

justingolden21 commented 1 month ago

Currently encountering this in 2024