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

Hang when hovering over constant #16907

Closed
DaniPopes opened this issue Mar 21, 2024 · 6 comments · Fixed by #16935
Closed

Hang when hovering over constant #16907

DaniPopes opened this issue Mar 21, 2024 · 6 comments · Fixed by #16935
Labels
A-mir Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@DaniPopes
Copy link
Contributor

DaniPopes commented Mar 21, 2024

rust-analyzer version:

  • 0.3.1885-standalone (b6d1887 2024-03-17)
  • 0.4.1889-standalone (5e276ae 2024-03-20)
  • 0.0.0 (8d74705 2024-03-21)

rustc version: rustc 1.79.0-nightly (a7e4de13c 2024-03-19)

relevant settings: N/A

repository link (if public, optional): N/A

code snippet to reproduce:

pub enum AA {
    BB,
}

pub fn hang() -> AA {
    const CONST: AA = AA::BB;
    CONST
}

Hovering over either CONST starts the hang and rust-analyzer becomes unresponsive, consuming about ~200MiB RAM per second in this case, though in other cases it can be much faster.

The server cannot be killed through hovering on the rust-analyzer button on the lower bar or with rust-analyzer: Stop server, and must be killed through the command line. It is either non-responsive or doesn't kill the process.

I can reproduce this consistently with recent rust-analyzer client and server, but only after updating rustc from nightly-2024-03-19 (rustc 1.79.0-nightly (3c85e5624 2024-03-18)) to nightly-2024-03-20 (rustc 1.79.0-nightly (a7e4de13c 2024-03-19)) or later with rustup (override works too).

@DaniPopes DaniPopes added the C-bug Category: bug label Mar 21, 2024
@Veykril
Copy link
Member

Veykril commented Mar 21, 2024

rust-lang/rust#122037 might be at fault here. Presumably this broke something in our mir eval, commit range diff rust-lang/rust@7f9830b

@Veykril Veykril added the A-mir label Mar 21, 2024
@HKalbasi
Copy link
Member

rust-lang/rust#122037 indeed needs some action, we need to consider function annotated with #[rust_intrinsic] or #[rust_safe_intrinsic] as intrinsic in addition to extern "rust-intrinsic" functions. But it is not clear to me how this simple example needs to call intrinsics. @DaniPopes did enum AA in your example has Debug implementation?

@Nikaidou-Shinku
Copy link

I encountered the same problem, in my case const FOO: [&'static str; 1] = ["bar"] would trigger the same problem.

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

I'm taking a look at fixing this by handling the new intrinsics correctly.

@Noratrieb
Copy link
Member

Uh, r-a's implementation of panic_fmt calls std::fmt::format... I guess that then in turn panics or something like that. I think it needs to call const_panic_fmt, just like rustc. #15222 introduced this with no information whatsoever 🤔 @HKalbasi
I suspect what happened is that something now cause std::fmt::format to panic, leading to pathological escpaing.
Because all the code is doing is escaping the panic message, and then escaping that, and escaping that etc, in just a few seconds we get gigabytes of backslashes, lmao.

@DrewMcArthur
Copy link

@Nilstrieb in case it's helpful at all, i added this comment to a closed issue before i realized that this and #16934 were both still open. memory is leaking for me whenever vs code tries to format-on-save, which sounds like it's related to your last comment here.

#16140 (comment)

@bors bors closed this as completed in 6f6b03f Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir 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.

6 participants