Recursive macro bypasses recursion limit, causes memory leak #105830
Labels
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-bug
Category: This is a bug.
I-crash
Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The following code causes rustc to get stuck on compiling while memory usage skyrockets, until it gets killed by the OOM killer.
The most important part of this is the
asdasd
text inbetween the two expansions. The memory leak only happens when some non-whitespace text is present there. I've tested several variations of text in that position and they all caused the issue:recursive!($($t)* asdasd $($t)*);
recursive!($($t)* ; $($t)*);
recursive!($($t)* | $($t)*);
recursive!($($t)* , $($t)*);
etc.
That is to say, when that line of code only has whitespace inbetween the two expansions:
recursive!($($t)* $($t)*);
the issue does not occur, and the compiler instantly terminates with a recursion limit error as it should:Output with only whitespace
Meta
This issue occurs both on stable and nightly.
rustc --version --verbose
:Backtrace
When run via
cargo build
(After stalling for ~30s):When run via
rustc src/main.rs
(After stalling for ~30s):Adding
RUST_BACKTRACE=1
to either of the above commands does not change the output at all.The text was updated successfully, but these errors were encountered: