-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The macro recursion limit is too low #22552
Comments
You don't need recursion for this macro, was your original usecase more complicated? |
Yeah, it got truncated when copying :P How would I implement the macro without recursion? |
macro_rules! check_errno {
($($errno:ident),+) => {{
$( assert_errno_eq(stringify!($errno), $errno as c_int); )+
}}
} |
/cc @rust-lang/lang, @rust-lang/compiler is there any discussion on what this limit should be? |
@steveklabnik IMO we should implement macro expansion without recursing in the compiler. |
@eddyb Isn't the recursion limit supposed to prevent never-terminating compilations? Being able to stack-overflow the compiler with a That said, the recursion limit isn't doing a very good job if this is what it's supposed to do: macro_rules! m {
( $( $i:ident )* ) => {
m!( $($i)* $($i)* )
};
}
fn main() {
let i = m!(m);
} This hangs, but doesn't cause a stack overflow. Memory usage slowly increases starting at about 100 MB. |
Macros and monomorphization both recurse in the Rust compiler and would otherwise end up in stack overflows. |
This has been encountered in the wild once more (#38541). I'm going to mark this as E-easy since I think the primary thing that needs to change is just this https://github.com/rust-lang/rust/blob/master/src/libsyntax/ext/expand.rs#L1041 line, which needs to be updated to a larger value. I'm going to suggest 1024. @jseyfried Do you agree with the easy designation? |
I would be interested in taking this one as a good way to figure out the process of contributing. |
@sirideain Great! Let us know if you need assistance. |
cc @nikomatsakis Another good use for stacker! |
…fried Increase macro recursion limit to 1024 Fixes #22552
I started hitting the recursion limit with the following macro (which isn't actually complete yet either)
The text was updated successfully, but these errors were encountered: