rust-lang / rust-lang/rustfmt

RustFmt takes entire ram when formatting simple(broken) file

Open
#5,752 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-memory-usage S-has-mcve
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

rustfmt 1.5.2-nightly (a41fc00 2023-04-13)

File

cfg_if::cfg_if! {
    if #[cfg(any(
        all(target_arch = "wasm32", not(target_os = "wasi")),
        target_arch = "asmjs"
    ))] {
        #[cfg(all(feature = "stdweb", not(feature = "wasm-bindgen")))]
        extern crate stdweb;

        mod wasm;
        pub use wasm::Instant;
        pub use crate::wasm::now;
        pub use wasm::SystemTime;
    } else {
        mod native;
        pub use native::Instant;
    %=    pub use native::now;
    }
}

will take 20GB ram and upset my oom killer which will kill process

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report with rustfmt 1.5.2-nightly (a41fc00 2023-04-13) and the Rust snippet in the issue. Trace formatting of the malformed %= line and identify why memory grows; done means the input is handled without exhausting system memory.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.