rust-lang / rust-lang/rust

Macro Expansion Hangs/OOMs

Open
#146,767 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-macros C-bug I-compilemem I-hang S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

macro_rules! m {
    [ $( $( ),+ )* ] => {}
}

m! {}

The above code hangs and quickly exhausts memory. This happens on nightly and dates back all the way back to version 1.0.0.

You can safely run the code on the playground here.

This bug was found using fuzzing.

@rustbot label +C-bug +A-macros +I-hang +S-has-mcve

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 running the minimal macro example from the issue, including the linked Rust Playground reproduction, and confirm the hang and memory exhaustion. Trace macro expansion for this input and add a regression test demonstrating that it terminates without exhausting memory; done means the reproducer completes normally while preserving valid macro behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.