Skip to content

rustc hanging indefinitely and using more and more memory #32572

Closed
@yberreby

Description

@yberreby

When compiling a particular piece of code, rustc hangs and keeps allocating memory indefinitely. I noticed this because my computer suddenly started swapping, and I found out rustc was using around 6GB of memory and growing.

Here's the code that triggered the bug:

pub enum PrimaryExpr {
    Indexing(PrimaryExpr, Expression),
    Slicing(PrimaryExpr, Slice),
}

Yes, nothing else - no dependencies, no modules, nothing.

Trying to compile it triggers the bug (src/lib.rs contains only the above snippet):

$ cat src/lib.rs
pub enum PrimaryExpr {
    Indexing(PrimaryExpr, Expression),
    Slicing(PrimaryExpr, Slice),
}

$ rustc src/lib.rs
src/lib.rs:2:27: 2:37 error: type name `Expression` is undefined or not in scope [E0412]
src/lib.rs:2     Indexing(PrimaryExpr, Expression),
                                       ^~~~~~~~~~
src/lib.rs:2:27: 2:37 help: run `rustc --explain E0412` to see a detailed explanation
src/lib.rs:2:27: 2:37 help: no candidates by the name of `Expression` found in your project; maybe you misspelled the name or forgot to import an external crate?
src/lib.rs:3:26: 3:31 error: type name `Slice` is undefined or not in scope [E0412]
src/lib.rs:3     Slicing(PrimaryExpr, Slice),
                                      ^~~~~
src/lib.rs:3:26: 3:31 help: run `rustc --explain E0412` to see a detailed explanation
src/lib.rs:3:26: 3:31 help: you can import it into scope: `use std::raw::Slice;`.
error: main function not found

rustc reports the error normally, but instead of exiting afterward it stays alive and keeps allocating more memory until I manually kill it.

Meta

$ rustc --version -v
rustc 1.9.0-nightly (d5a91e6 2016-03-26)
binary: rustc
commit-hash: d5a91e6
commit-date: 2016-03-26
host: x86_64-apple-darwin
release: 1.9.0-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions