Skip to content

rustc runs out of memory when compiling an invalid macro #37113

Closed
@jbendig

Description

@jbendig

Compiling this invalid macro code with rustc causes all system memory to be used up until the process is killed.

macro_rules! test_macro {
    ( $( $t:ty ),* $(),*) => {
        enum SomeEnum {
            $( $t, )*
        };
    };
}

fn main() {
    test_macro!(String,);
}

I expected rustc to display an error message and return immediately. Instead, an error message is reported and then rustc hangs and eats up all available system memory.

I tried both stable and nightly:

  • stable-x86_64-unknown-linux-gnu - rustc 1.12.0 (3191fba 2016-09-23)
  • nightly-x86_64-unknown-linux-gnu - rustc 1.14.0-nightly (a3bc191 2016-10-10)

I think this might be related to #33136.

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