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 Analyzer Language Server crashes on big Rust files on VSCode. #18223

Closed
AngheloAlf opened this issue Oct 1, 2024 · 6 comments · Fixed by #18255
Closed

Rust Analyzer Language Server crashes on big Rust files on VSCode. #18223

AngheloAlf opened this issue Oct 1, 2024 · 6 comments · Fixed by #18255
Assignees

Comments

@AngheloAlf
Copy link

AngheloAlf commented Oct 1, 2024

The Rust Analyzer extension crashes when opening a big Rust file.
This file is 24000 lines long and only contain test code. I had to move all this test code to its own file because it was messing with the analyzer extension.
The extension works fine if I completely ignore this file and don't open at all.

Here's a link to the file that produces Rust Analyzer to crash: https://github.com/Decompollaborate/rabbitizer/blob/8a429c863e2c451b47bc0fe74a4e6a776f470356/src/rabbitizer/tests/instruction_tests_r4000allegrex.rs

The only "workaround" I can find for the analyzer crashing is to restart the rust analyzer server or restart all vscode extensions by doing ctrl-shift-P and select rust-analyzer: Restart server or Developer: Restart extension host respectively. After the extension is restarted it will crash again if I still have the file open though.

I saw there are other issues mentioning problems with big files (ie #13807 ), but most of them mention OOM or the extension eating all the RAM, but I did not notice any significant difference on the RAM usage when this issue happens.

To reproduce:

Minimized repo

I made a "minimized" repo that still reproduces the issue: https://github.com/AngheloAlf/rust_analyzer_crash
The problematic file is at https://github.com/AngheloAlf/rust_analyzer_crash/blob/big_file_crash/src/big_tests.rs

When the analyzer crashes vscode shows the following pop-up:
Image

This is all the logs the OUTPUT tab has:


thread 'Worker' has overflowed its stack
fatal runtime error: stack overflow
[Info  - 11:26:42] Connection to server got closed. Server will restart.
true

thread 'Worker' has overflowed its stack
fatal runtime error: stack overflow
[Info  - 11:26:51] Connection to server got closed. Server will restart.
true

thread 'Worker' has overflowed its stack
fatal runtime error: stack overflow
[Info  - 11:27:01] Connection to server got closed. Server will restart.
true

thread 'Worker' has overflowed its stack
fatal runtime error: stack overflow
[Info  - 11:27:10] Connection to server got closed. Server will restart.
true

thread 'Worker' has overflowed its stack
fatal runtime error: stack overflow
[Error - 11:27:20] The Rust Analyzer Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Versions info

cargo --version: cargo 1.81.0 (2dbb1af80 2024-08-20)
VSCode version: 1.93.1
rust-analyzer vscode extension version: v0.3.2129
OS: Pop!_OS 22.04

@ChayimFriedman2
Copy link
Contributor

Does "rust-analyzer: Restart server" does not work?

@AngheloAlf
Copy link
Author

Does "rust-analyzer: Restart server" does not work?

You are right, it does work, but the extension still crashes with the big file open.
I'll update the issue to mention this option too.

@ChayimFriedman2
Copy link
Contributor

It is weird the stack is overflowed on this file; it doesn't seem to have particularly deep nesting.

This is quite big repository; can you try minimizing it (not necessary, but that will help us)? In particular, try removing all other files and put it at the root and see if it still crashes.

@Veykril
Copy link
Member

Veykril commented Oct 2, 2024

It is weird the stack is overflowed on this file; it doesn't seem to have particularly deep nesting.

My hunch would be that this overflows somehow in mir building / interpreting maybe given that works on basic blocks which might be recursive in evaluation? (just guessing here)

@AngheloAlf
Copy link
Author

This is quite big repository; can you try minimizing it (not necessary, but that will help us)? In particular, try removing all other files and put it at the root and see if it still crashes.

I made a "minimized" repo that still reproduces the issue: https://github.com/AngheloAlf/rust_analyzer_crash
The problematic file is at https://github.com/AngheloAlf/rust_analyzer_crash/blob/big_file_crash/src/big_tests.rs

let me know if there's anything else I can do to help diagnose this issue.

@ChayimFriedman2
Copy link
Contributor

This is quite big repository; can you try minimizing it (not necessary, but that will help us)? In particular, try removing all other files and put it at the root and see if it still crashes.

I made a "minimized" repo that still reproduces the issue: https://github.com/AngheloAlf/rust_analyzer_crash The problematic file is at https://github.com/AngheloAlf/rust_analyzer_crash/blob/big_file_crash/src/big_tests.rs

let me know if there's anything else I can do to help diagnose this issue.

Thanks!

It is weird the stack is overflowed on this file; it doesn't seem to have particularly deep nesting.

My hunch would be that this overflows somehow in mir building / interpreting maybe given that works on basic blocks which might be recursive in evaluation? (just guessing here)

I don't think evaluation/building should be recursive, it seems very wrong. I'll take a look at it.

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants