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

rust-analyser hangs at "Fetching", and uses CPU at 100% #16614

Closed
lmsonic opened this issue Feb 20, 2024 · 30 comments · Fixed by #16616 or #16645
Closed

rust-analyser hangs at "Fetching", and uses CPU at 100% #16614

lmsonic opened this issue Feb 20, 2024 · 30 comments · Fixed by #16616 or #16645
Assignees
Labels
Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@lmsonic
Copy link

lmsonic commented Feb 20, 2024

rust-analyzer version: 0.3.1850 (latest at time of writing)

rustc version: rustc 1.78.0-nightly (3246e7951 2024-02-19)

System specs:
Windows 10
Processor 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz 2.30 GHz
Installed RAM 16,0 GB (15,8 GB usable)
System type 64-bit operating system, x64-based processor

relevant settings:
Project is a bevy project setup as in this link https://bevyengine.org/learn/quick-start/getting-started/setup/ (I am using VSCode)

# Cargo.toml

[dependencies]
bevy = { version = "0.12.0", features = ["dynamic_linking"] }

# Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1

# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3

# .cargo/config.toml
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe" # Use LLD Linker
rustflags = [
    "-Zshare-generics=n",
    "-Zthreads=0",        # (Nightly) Use improved multithreading with the recommended amount of threads.
]

# Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only'
# In most cases the gains are negligible, but if you are on macos and have slow compile times you should see significant gains.
[profile.dev]
debug = 1
# Rust analyser settings in vscode
    "rust-analyzer.server.extraEnv": {
        "CARGO_TARGET_DIR": "target/analyzer",
    },
    "rust-analyzer.check.extraArgs": [
        "--target-dir=target/analyzer"
    ],
    "rust-analyzer.cargo.extraEnv": {
        "CARGO_PROFILE_RUST_ANALYZER_INHERITS": "dev",
        "RUSTFLAGS": "-Clinker=rust-lld.exe"
    },
    "rust-analyzer.cargo.extraArgs": [
        "--profile",
        "rust-analyzer"
    ],
    "rust-analyzer.check.overrideCommand": [
        "cargo",
        "clippy",
        "--workspace",
        "--message-format=json",
        "--all-targets",
    ],

Like in the title, rust-analyser hangs at "Fetching" when starting the project, if I click on show logs it doesn't show anything, but it keeps using the CPU with multiple rustc processes at 100%. I tried cleaning up the cache, reinstalling rust, messing with num thread and cache priming settings, but nothing worked.

The only thing that worked to make it usable was to revert to v0.3.1839, and now everything works fine. I will stay on that for now until it gets fixed :)

@lmsonic lmsonic added the C-bug Category: bug label Feb 20, 2024
@qoheniac
Copy link

Another workaround is to use the pre-release version 0.4.1851

@iNeXcf
Copy link

iNeXcf commented Feb 20, 2024

For me pre-release version 0.4.1851 and version 0.3.1850 show the same behavior. v0.3.1839 is working correctly.

@Veykril
Copy link
Member

Veykril commented Feb 20, 2024

This seems to be non-deterministic ...

@freezdream
Copy link

Also affected. Fetching eventually finishes, but it easily takes half an hour. Afterwards it is responsive until I run a build on the command line (which, after rust-analyzer ran requires rebuilding half the application starting from proc_macro2, even if there were no changes).
So it seems like rust-analzer invalidates regular builds and vice versa.

Reverting back to 0.3.1839 fixed the issue for me as well.

@Veykril
Copy link
Member

Veykril commented Feb 20, 2024

Most likely caused by #16537 / #16563, I only ran into it once earlier but I can't seem to reproduce it now.

@Veykril Veykril added the Broken Window Bugs / technical debt to be addressed immediately label Feb 20, 2024
@Veykril
Copy link
Member

Veykril commented Feb 20, 2024

Actually it could beis #16247

@Veykril Veykril self-assigned this Feb 20, 2024
@Veykril
Copy link
Member

Veykril commented Feb 20, 2024

For the time being you can disable rust-analyzer.cargo.buildScripts.rebuildOnSave, that should avoid the issue until a fix is landed I think.

@Veykril
Copy link
Member

Veykril commented Feb 20, 2024

#16616 should fix this I believe, I pushed out a new nightly release if some of you could check with the rust-analyzer.cargo.buildScripts.rebuildOnSave enabled again on that release that would be great

@lmsonic
Copy link
Author

lmsonic commented Feb 20, 2024

v0.4.1852 is still hanging for me :c

@Veykril Veykril reopened this Feb 20, 2024
@tauanbinato
Copy link

Same here, downgraded to 0.3.1839

@EliiasG
Copy link

EliiasG commented Feb 21, 2024

Mine was also fetching for about 10 minutes, deleting some of the compiled project and seemed to have a hard time determining types, reverting to 0.3.1839 also fixed mine.

@pvini07BR
Copy link

same here. both in stable v0.3.1850 and in v0.4.1853 (pre-release).

@newDINO
Copy link

newDINO commented Feb 22, 2024

Same for me in Linux. Both v0.3.1850 in vscode and v20240219 for helix I encountered similar problem.
Once I launched the editor, there would be multiple rustc running in bachground for a long time.'

Another issure: when the analyzer found #![cfg_attr(rustc_attrs, feature(rustc_attrs))] error in a dependency crate, it stopped error checking in the workspace, but I can still compile the project without this error.

@Mclilzee
Copy link

The problem for me got fixed after changing rustc to nightly version. rustup default nightly. Make sure to build your project with cargo build before you open your editor, which will launch rust-analyzer and index it. Otherwise, your rust-analyzer will have to compile by itself, which will result in a very long wait time if you are building bevy.

@Veykril
Copy link
Member

Veykril commented Feb 22, 2024

In general it seems that the issue can be sidestepped by first building the project via a manual cargo invocation before loading up rust-analyzer. I'll try looking into this more by the end of the week.

@Mclilzee
Copy link

In general it seems that the issue can be sidestepped by first building the project via a manual cargo invocation before loading up rust-analyzer. I'll try looking into this more by the end of the week.

@Veykril That is not exactly what was happening to me, that's how I used to do it before the problem arose, I would build because otherwise the indexing will take much longer.

As of right now After running cargo build I open the files for editing, and rust-analyzer get stuck at fetching. The fetching phase takes as long as the building phase, as if rust-analyzer have to rebuild everything itself before indexing. After that the build I did previously with cargo build gets invalidated, so no incremental builds and if I build it again then it will have to build it all over again from the start and takes as long as it did the first time.

And If I open the project again now, rust-analyzer does what it did again and rebuild + invalidate my manual cargo build. Even if I close my editor and re-open again without running cargo build, rust-analyzer will do it again from the start. And this will keep happening unless I have the analyzer already indexed and build through built in terminal.

There were various steps I took to try and address this problem, including setting analyzerTargetDir to true. In the end, as of right now, I'm not exactly sure what fixed the issue for me. Nightly seems not to be the fix, when I switched back to stable I found that the problem has come back, but switching back to nightly didn't fix it this time.

Apparently I could get rid of the problem by disabling opt builds and the dynamic_linking but only on nightly rustc, stable still has the issue even with those disabled.

@Veykril
Copy link
Member

Veykril commented Feb 22, 2024

Build invalidation is a different problem than the one described here. I am having problems reproducing this issue again right now (been trying to bisect it with no luck)

@jquesada2016
Copy link

I'm running into this issue. My fix is to uninstall rust-analyzer in VS Code, and reinstall. It'll work fine into the next time I open the editor.

@hurlebouc
Copy link

hurlebouc commented Feb 23, 2024

Hi. For me it still stuck after uninstalling and reinstalling version v0.3.1850. Stucked message is

Building: building proc-macros: <APP_NAME>

(similar to #16605)

@hurlebouc
Copy link

hurlebouc commented Feb 23, 2024

I finally solved my problem by updating my toolchain (rustup update) from version 1.75.0 to 1.76.0

@Veykril
Copy link
Member

Veykril commented Feb 23, 2024

Updating the toolchain helps? 🤨 now that would be very confusing to me.

@Veykril
Copy link
Member

Veykril commented Feb 23, 2024

Just ran into it again earlier, from the looks of it it seems that the server deadlocks somewhere

@Veykril
Copy link
Member

Veykril commented Feb 23, 2024

Alright it can easily be reproduced by just editing a proc-macro in the loaded workspace, captured a backtrace of the running lsp-server

Thread 15 (Thread 0x7f7a8428e6c0 (LWP 295029) "Flycheck"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x00005652531a05f4 in crossbeam_channel::select::run_select::{{closure}}::ha5e2f8d8689948c6 ()
#5  0x000056525319fbf1 in crossbeam_channel::select::run_select::he699a5678869e690 ()
#6  0x00005652531d35b7 in flycheck::FlycheckActor::run::h61d6351822171fa6 ()
#7  0x00005652531e9289 in std::sys_common::backtrace::__rust_begin_short_backtrace::h9b8ab6087195d8cb ()
#8  0x00005652531ea758 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h5b7854b081a00306 ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
--Type <RET> for more, q to quit, c to continue without paging--
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 14 (Thread 0x7f7a74ff96c0 (LWP 294970) "Worker"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x00005652545bb36a in crossbeam_channel::flavors::list::Channel<T>::recv::{{closure}}::h9ed0a3443829ddf5 ()
#5  0x00005652545baaee in crossbeam_channel::flavors::list::Channel<T>::recv::h205fffa9d681c4f8 ()
#6  0x00005652545bec42 in <crossbeam_channel::channel::IntoIter<T> as core::iter::traits::iterator::Iterator>::next::hf1b5ce3728684dc8 ()
#7  0x00005652545c3915 in std::sys_common::backtrace::__rust_begin_short_backtrace::h837d570307dbde36 ()
#8  0x00005652545c4469 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ce62244e9cd5a2c ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 13 (Thread 0x7f7a757fa6c0 (LWP 294969) "Worker"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x00005652545bb36a in crossbeam_channel::flavors::list::Channel<T>::recv::{{closure}}::h9ed0a3443829ddf5 ()
#5  0x00005652545baaee in crossbeam_channel::flavors::list::Channel<T>::recv::h205fffa9d681c4f8 ()
#6  0x00005652545bec42 in <crossbeam_channel::channel::IntoIter<T> as core::iter::traits::iterator::Iterator>::next::hf1b5ce3728684dc8 ()
#7  0x00005652545c3915 in std::sys_common::backtrace::__rust_begin_short_backtrace::h837d570307dbde36 ()
#8  0x00005652545c4469 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ce62244e9cd5a2c ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 12 (Thread 0x7f7a75ffb6c0 (LWP 294968) "Worker"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x00005652545bb36a in crossbeam_channel::flavors::list::Channel<T>::recv::{{closure}}::h9ed0a3443829ddf5 ()
#5  0x00005652545baaee in crossbeam_channel::flavors::list::Channel<T>::recv::h205fffa9d681c4f8 ()
#6  0x00005652545bec42 in <crossbeam_channel::channel::IntoIter<T> as core::iter::traits::iterator::Iterator>::next::hf1b5ce3728684dc8 ()
#7  0x00005652545c3915 in std::sys_common::backtrace::__rust_begin_short_backtrace::h837d570307dbde36 ()
#8  0x00005652545c4469 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ce62244e9cd5a2c ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 11 (Thread 0x7f7a767fc6c0 (LWP 294967) "Worker"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
--Type <RET> for more, q to quit, c to continue without paging--
#1  0x0000565253107e8d in parking_lot::raw_rwlock::RawRwLock::lock_shared_slow::h69a4e2cc9a11d27f ()
#2  0x0000565254480afd in rust_analyzer::global_state::GlobalStateSnapshot::file_line_index::hddf3ed3530314f23 ()
#3  0x000056525449ee4d in core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h3f34e2e2f973e370 ()
#4  0x00005652541c7b98 in <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter::hb1b8f4a432c1f096 ()
#5  0x00005652544c161e in rust_analyzer::diagnostics::fetch_native_diagnostics::hb18db51c72699476 ()
#6  0x00005652541e2164 in core::ops::function::FnOnce::call_once{{vtable.shim}}::hb9c73e78f096871e ()
#7  0x00005652545c3936 in std::sys_common::backtrace::__rust_begin_short_backtrace::h837d570307dbde36 ()
#8  0x00005652545c4469 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ce62244e9cd5a2c ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 10 (Thread 0x7f7a76ffd6c0 (LWP 294966) "Worker"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x00005652545bb36a in crossbeam_channel::flavors::list::Channel<T>::recv::{{closure}}::h9ed0a3443829ddf5 ()
#5  0x00005652545baaee in crossbeam_channel::flavors::list::Channel<T>::recv::h205fffa9d681c4f8 ()
#6  0x00005652545bec42 in <crossbeam_channel::channel::IntoIter<T> as core::iter::traits::iterator::Iterator>::next::hf1b5ce3728684dc8 ()
#7  0x00005652545c3915 in std::sys_common::backtrace::__rust_begin_short_backtrace::h837d570307dbde36 ()
#8  0x00005652545c4469 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ce62244e9cd5a2c ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 9 (Thread 0x7f7a777fe6c0 (LWP 294965) "Worker"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x00005652545bb36a in crossbeam_channel::flavors::list::Channel<T>::recv::{{closure}}::h9ed0a3443829ddf5 ()
#5  0x00005652545baaee in crossbeam_channel::flavors::list::Channel<T>::recv::h205fffa9d681c4f8 ()
#6  0x00005652545bec42 in <crossbeam_channel::channel::IntoIter<T> as core::iter::traits::iterator::Iterator>::next::hf1b5ce3728684dc8 ()
#7  0x00005652545c3915 in std::sys_common::backtrace::__rust_begin_short_backtrace::h837d570307dbde36 ()
#8  0x00005652545c4469 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ce62244e9cd5a2c ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 8 (Thread 0x7f7a77fff6c0 (LWP 294964) "Worker"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x00005652545bb36a in crossbeam_channel::flavors::list::Channel<T>::recv::{{closure}}::h9ed0a3443829ddf5 ()
#5  0x00005652545baaee in crossbeam_channel::flavors::list::Channel<T>::recv::h205fffa9d681c4f8 ()
#6  0x00005652545bec42 in <crossbeam_channel::channel::IntoIter<T> as core::iter::traits::iterator::Iterator>::next::hf1b5ce3728684dc8 ()
--Type <RET> for more, q to quit, c to continue without paging--
#7  0x00005652545c3915 in std::sys_common::backtrace::__rust_begin_short_backtrace::h837d570307dbde36 ()
#8  0x00005652545c4469 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ce62244e9cd5a2c ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 7 (Thread 0x7f7a84a8f6c0 (LWP 294963) "Worker"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x00005652545bb36a in crossbeam_channel::flavors::list::Channel<T>::recv::{{closure}}::h9ed0a3443829ddf5 ()
#5  0x00005652545baaee in crossbeam_channel::flavors::list::Channel<T>::recv::h205fffa9d681c4f8 ()
#6  0x00005652545bec42 in <crossbeam_channel::channel::IntoIter<T> as core::iter::traits::iterator::Iterator>::next::hf1b5ce3728684dc8 ()
#7  0x00005652545c3915 in std::sys_common::backtrace::__rust_begin_short_backtrace::h837d570307dbde36 ()
#8  0x00005652545c4469 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ce62244e9cd5a2c ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 6 (Thread 0x7f7a852906c0 (LWP 294962) "Worker"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x00005652545bb36a in crossbeam_channel::flavors::list::Channel<T>::recv::{{closure}}::h9ed0a3443829ddf5 ()
#5  0x00005652545baaee in crossbeam_channel::flavors::list::Channel<T>::recv::h205fffa9d681c4f8 ()
#6  0x00005652545bec42 in <crossbeam_channel::channel::IntoIter<T> as core::iter::traits::iterator::Iterator>::next::hf1b5ce3728684dc8 ()
#7  0x00005652545c3915 in std::sys_common::backtrace::__rust_begin_short_backtrace::h837d570307dbde36 ()
#8  0x00005652545c4469 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ce62244e9cd5a2c ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 5 (Thread 0x7f7a854916c0 (LWP 294961) "VfsLoader"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x00005652531a05f4 in crossbeam_channel::select::run_select::{{closure}}::ha5e2f8d8689948c6 ()
#5  0x000056525319fbf1 in crossbeam_channel::select::run_select::he699a5678869e690 ()
#6  0x000056525465769c in vfs_notify::NotifyActor::run::h86e4f3b30711491e ()
#7  0x000056525465edaf in std::sys_common::backtrace::__rust_begin_short_backtrace::hccfa91c4fbbe31d3 ()
#8  0x000056525465d4a8 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h38989adcaa079624 ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
--Type <RET> for more, q to quit, c to continue without paging--
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 4 (Thread 0x7f7a856926c0 (LWP 294960) "LspServer"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x0000565254035273 in crossbeam_channel::context::Context::wait_until::hba12e4ce3bf53473 ()
#5  0x00005652540371ff in crossbeam_channel::flavors::zero::Channel<T>::send::{{closure}}::h465e2abd7eb8899b ()
#6  0x0000565254036d86 in crossbeam_channel::flavors::zero::Channel<T>::send::h6bfc560c732050fc ()
#7  0x000056525403c642 in crossbeam_channel::channel::Sender<T>::send::h2f6f34d439c6c1d2 ()
#8  0x0000565254038b80 in std::sys_common::backtrace::__rust_begin_short_backtrace::h27a71de14bb7d0ba ()
#9  0x0000565254033446 in core::ops::function::FnOnce::call_once{{vtable.shim}}::he865970cc0ab613b ()
#10 0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#12 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#13 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#14 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 3 (Thread 0x7f7a858936c0 (LWP 294959) "LspServer"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254592464 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62
#2  std::sys_common::thread_parking::futex::Parker::park () at library/std/src/sys_common/thread_parking/futex.rs:52
#3  std::thread::park () at library/std/src/thread/mod.rs:1066
#4  0x0000565254035273 in crossbeam_channel::context::Context::wait_until::hba12e4ce3bf53473 ()
#5  0x00005652540362a4 in crossbeam_channel::flavors::zero::Channel<T>::recv::{{closure}}::h26a83723b56c6e60 ()
#6  0x00005652540359d5 in crossbeam_channel::flavors::zero::Channel<T>::recv::h5891bf0a61c77f8d ()
#7  0x000056525403cb40 in crossbeam_channel::channel::Receiver<T>::recv::hb94d6edcefb508bb ()
#8  0x0000565254038e7d in std::sys_common::backtrace::__rust_begin_short_backtrace::h5c3620a70b3d69e3 ()
#9  0x00005652540331f6 in core::ops::function::FnOnce::call_once{{vtable.shim}}::hb899b53e74d00b44 ()
#10 0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#12 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#13 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#14 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 2 (Thread 0x7f7a860946c0 (LWP 294958) "LspServer"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254069e8f in parking_lot::raw_rwlock::RawRwLock::wait_for_readers::h738f940a0cbc6635 ()
#2  0x0000565253107479 in parking_lot::raw_rwlock::RawRwLock::lock_exclusive_slow::h0730d6989cf7aa3c ()
#3  0x000056525455824f in salsa::runtime::Runtime::synthetic_write::h4e12549d06a78c05 ()
#4  0x0000565253f0119b in ide_db::apply_change::<impl ide_db::RootDatabase>::request_cancellation::h96b6a76b464e489e ()
#5  0x0000565253f01348 in ide_db::apply_change::<impl ide_db::RootDatabase>::apply_change::h12ca3b554fe39d4a ()
#6  0x000056525448ea0d in rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::recreate_crate_graph::h47bb29279ead9bb7 ()
#7  0x000056525448db69 in rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::switch_workspaces::h82501e7eb9771ffa ()
#8  0x0000565254489664 in rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_task::h3ea66742651ee0a9 ()
#9  0x0000565254483e12 in rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event::h8f1a61ee4dc065e9 ()
#10 0x0000565254482251 in rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run::h0bbd169bbfb6ed79 ()
#11 0x00005652543e49ea in rust_analyzer::main_loop::main_loop::h9652359aad0a65bb ()
#12 0x00005652545113c2 in rust_analyzer::run_server::he1464b1970a77727 ()
#13 0x000056525451af66 in std::sys_common::backtrace::__rust_begin_short_backtrace::hdb18004c5d51992c ()
#14 0x0000565254509eb5 in core::ops::function::FnOnce::call_once{{vtable.shim}}::hac3f57450b5000fe ()
#15 0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#16 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
--Type <RET> for more, q to quit, c to continue without paging--
#17 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#18 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#19 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7f7a86095a00 (LWP 294957) "rust-analyzer"):
#0  0x00007f7a861234ae in ?? () from /usr/lib/libc.so.6
#1  0x00007f7a861285f3 in ?? () from /usr/lib/libc.so.6
#2  0x000056525450998b in std::thread::JoinInner<T>::join::h3a93e2db8b68e79c ()
#3  0x000056525454ad87 in jod_thread::JoinHandle<T>::join::hacf0eb286c8d1c56 ()
#4  0x000056525450f682 in rust_analyzer::main::hcb72aa805c6a6e90 ()
#5  0x000056525451af56 in std::sys_common::backtrace::__rust_begin_short_backtrace::h3d9500aa313fa48b ()
#6  0x0000565254520872 in std::rt::lang_start::{{closure}}::hc5a3572342038e4e ()
#7  0x0000565254591f05 in core::ops::function::impls::{impl#2}::call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> () at library/core/src/ops/function.rs:284
#8  std::panicking::try::do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> () at library/std/src/panicking.rs:552
#9  std::panicking::try<i32, &(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> () at library/std/src/panicking.rs:516
#10 std::panic::catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> () at library/std/src/panic.rs:142
#11 std::rt::lang_start_internal::{closure#2} () at library/std/src/rt.rs:148
#12 std::panicking::try::do_call<std::rt::lang_start_internal::{closure_env#2}, isize> () at library/std/src/panicking.rs:552
#13 std::panicking::try<isize, std::rt::lang_start_internal::{closure_env#2}> () at library/std/src/panicking.rs:516
#14 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#2}, isize> () at library/std/src/panic.rs:142
#15 std::rt::lang_start_internal () at library/std/src/rt.rs:148
#16 0x0000565254512055 in main ()

@Veykril
Copy link
Member

Veykril commented Feb 23, 2024

Looks like 11 and 2 are locking each other up?

Thread 11 (Thread 0x7f7a767fc6c0 (LWP 294967) "Worker"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565253107e8d in parking_lot::raw_rwlock::RawRwLock::lock_shared_slow::h69a4e2cc9a11d27f ()
#2  0x0000565254480afd in rust_analyzer::global_state::GlobalStateSnapshot::file_line_index::hddf3ed3530314f23 ()
#3  0x000056525449ee4d in core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h3f34e2e2f973e370 ()
#4  0x00005652541c7b98 in <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter::hb1b8f4a432c1f096 ()
#5  0x00005652544c161e in rust_analyzer::diagnostics::fetch_native_diagnostics::hb18db51c72699476 ()
#6  0x00005652541e2164 in core::ops::function::FnOnce::call_once{{vtable.shim}}::hb9c73e78f096871e ()
#7  0x00005652545c3936 in std::sys_common::backtrace::__rust_begin_short_backtrace::h837d570307dbde36 ()
#8  0x00005652545c4469 in core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ce62244e9cd5a2c ()
#9  0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#10 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#11 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#12 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#13 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Thread 2 (Thread 0x7f7a860946c0 (LWP 294958) "LspServer"):
#0  0x00007f7a861a873d in syscall () from /usr/lib/libc.so.6
#1  0x0000565254069e8f in parking_lot::raw_rwlock::RawRwLock::wait_for_readers::h738f940a0cbc6635 ()
#2  0x0000565253107479 in parking_lot::raw_rwlock::RawRwLock::lock_exclusive_slow::h0730d6989cf7aa3c ()
#3  0x000056525455824f in salsa::runtime::Runtime::synthetic_write::h4e12549d06a78c05 ()
#4  0x0000565253f0119b in ide_db::apply_change::<impl ide_db::RootDatabase>::request_cancellation::h96b6a76b464e489e ()
#5  0x0000565253f01348 in ide_db::apply_change::<impl ide_db::RootDatabase>::apply_change::h12ca3b554fe39d4a ()
#6  0x000056525448ea0d in rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::recreate_crate_graph::h47bb29279ead9bb7 ()
#7  0x000056525448db69 in rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::switch_workspaces::h82501e7eb9771ffa ()
#8  0x0000565254489664 in rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_task::h3ea66742651ee0a9 ()
#9  0x0000565254483e12 in rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event::h8f1a61ee4dc065e9 ()
#10 0x0000565254482251 in rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run::h0bbd169bbfb6ed79 ()
#11 0x00005652543e49ea in rust_analyzer::main_loop::main_loop::h9652359aad0a65bb ()
#12 0x00005652545113c2 in rust_analyzer::run_server::he1464b1970a77727 ()
#13 0x000056525451af66 in std::sys_common::backtrace::__rust_begin_short_backtrace::hdb18004c5d51992c ()
#14 0x0000565254509eb5 in core::ops::function::FnOnce::call_once{{vtable.shim}}::hac3f57450b5000fe ()
#15 0x00005652545a7835 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
#16 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2015
--Type <RET> for more, q to quit, c to continue without paging--
#17 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#18 0x00007f7a861269eb in ?? () from /usr/lib/libc.so.6
#19 0x00007f7a861aa7cc in ?? () from /usr/lib/libc.so.6

Hmm no that doesn't seem right, 11 is in a spinlock

0.4.1843 seems to be good, 0.4.1849 shows the issue, commit range b9b0d29...68c506f

@Veykril
Copy link
Member

Veykril commented Feb 23, 2024

Ah nevermind it is the two threads I think I found the problem

@Alsanis
Copy link

Alsanis commented Feb 23, 2024

Full rebuild (Fetching...) on each save ("rust-analyzer.checkOnSave": true). Extension version: v0.4.1856 (pre-release)
 Using Bevy 0.13 crate in project. Rust-analyser extension 0.3.1839 works fine.
 Am I do something wrong, or problem is still not solved?

@LucaSchwan
Copy link

LucaSchwan commented Mar 14, 2024

I'm also still having the issue where it hangs at building proc-macros: <PROJECT_NAME>. I'm using nvim and rust-analyzer 1.78.0-nightly (3cbb932 2024-03-13) currently. Is the fix not in nightly yet?

I am getting completions however, but no diagnostics for my code.

I don't exactly know the release cycle of nightly and stable yet, so there just might be something that I'm missing here.

@davidbarsky
Copy link
Contributor

I'm also still having the issue where it hangs at building proc-macros: <PROJECT_NAME>. I'm using nvim and rust-analyzer 1.78.0-nightly (3cbb932 2024-03-13) currently. Is the fix not in nightly yet?

I am getting completions however, but no diagnostics for my code.

I don't exactly know the release cycle of nightly and stable yet, so there just might be something that I'm missing here.

@LucaSchwan I'm not sure how you installed rust-analyzer, but the deadlock corresponding to this issue has been resolved and released. If you installed rust-analyzer through rustup, it seems like the last sync was four days ago: rust-lang/rust#122272.

@LucaSchwan
Copy link

@davidbarsky I am on NixOS and I'm using fenix with a flake to install the nightly toolchain.

@thinety
Copy link

thinety commented May 10, 2024

I'm also running into the building proc-macros: <PROJECT_NAME> issue. Tried toolchain versions 1.77.2, 1.78.0, 1.79.0-beta and 1.80.0-nightly via rustup but all of them present the problem. Downgrading to 1.76.0 (07dca48 2024-02-04) solved it for me, and I can confirm that 1.75.0 also works fine.

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