Closed
Description
Code:
#[macro_export]
macro_rules! memory_leak {
(
$(
/// <-- causes the memory leak
)*
) => {};
}
// must call at least once
memory_leak! {}
fn main() {}
Here are some playground links at which it also doesn't compile. (also does not work on release
)
Playground (2021; stable; debug)
Playground (2021; nightly; debug)
Steps to reproduce
- Save the code as
memory_leak.rs
- Run
rustc memory_leak.rs
Expected Behavior:
Raise an repetition matches empty token tree
compiler error, like a normal comment would, as an example:
#[macro_export]
macro_rules! works {
(
$(
// <-- notice the missing slash
)*
) => {};
}
works! {}
fn main() {}
What happened:
It entered an infinite loop and allocated infinite amount of memory. I have 16 GB of ram and 8 GB swap, at one point it got killed by the oom killer.
Meta
rustc --version --verbose
:
rustc 1.72.0-nightly (e6d4725c7 2023-06-05)
binary: rustc
commit-hash: e6d4725c76f3b526c74454bc51afdf6daf133506
commit-date: 2023-06-05
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.4
No backtrace available, as it gets killed by the oom killer