-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Severe memory leak in Rustc #78125
Copy link
Copy link
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitC-bugCategory: This is a bug.Category: This is a bug.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitC-bugCategory: This is a bug.Category: This is a bug.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
AFAICT, this isn't a security vulnerability, so I'm reporting this here.
I was attempting to build a RESTful CRUD API with Actix-web, and I've stumbled into a compiler bug. All the source files are about 150-200 LoC, so I'm not going to post them all here. The code that reproduces this bug is available at https://github.com/Davester47/rustc-leak. I left instructions to reproduce the leak in the README.md
To Reproduce:
When I try to compile it with
cargo build, it compiles all the dependencies fine. However, as soon as it gets to building the final binary ("snack-actix"), it starts leaking memory like crazy (500+ MB/s) and it never stops. It ran for over 10 minutes on the final phase on my Windows laptop, and I think it used over 15 GB of swap (I can't tell for sure on the task manager). On linux, the computer becomes unusable as soon as it starts using swap space.My advice if you try to reproduce this is to have Task Manager or
htopopen while you compile it, and be ready to hit Ctrl+C. It will use all of your memory if you don't.The last thing that I did before it started leaking memory was finish the function in src/controllers/snack.rs. I know that my code is probably bad style or not idiomatic or something, but it shouldn't use over 12 GBs of memory.
I don't know how I would find where the leak happens or why it happens, so I'm hoping someone here will be able to. Let me know if you need more information. Please don't let this issue get sidelined.
Meta
I've confirmed that the leak occurs on all of the following toolchains.
rustc --version --verbose:There's no backtrace, since I had to kill rustc with Ctrl+C every time to avoid crashing my computer (Sometimes I failed). I have 8 GBs of RAM, which should be enough to compile anything. It never panicked.