-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Infinite recursion in macro expansion crashes rustc #17628
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
Comments
We already have a |
I am looking into this issue. Howerver it seems like the same |
The |
…lexcrichton This is a patch for #17628, thanks to @kmcallister for your helpful hints!
@fhahn Now that recursion depth is limited, is there anyway to configure it from the command line? The current depth setting (64?) is too aggressive for some macro magic I am working on, that recurses heavily. |
I could at least increase it to 256 if that would help. Other than that someone else (@fhan maybe) should look into it. |
My patch did not include any method to customize the depth limit. I just used 64 because Another way to customize the recursion depth for macro expansions could be using something like Anyhow, if there is a decision to do it one way or another, I'd be happy to work on a patch. |
Could we at least for now bump the limit up to something much larger? The current setting of 64 is probably too low for macros that rely on reduction rules. (ie that match a portion of a statement and pass the remainder to another macro (often itself) for further expansion). I don't have a good handle on the expense of each macro expansion in terms of compiler memory/time ... but is there any reason for it not to be a number on a much larger scale, such as 1024? |
I like the idea of a file/crate attribute to govern the recursion depth of macros expanded within that crate. |
I will try to increase it to 2048. Someone else should maybe look into the attribute or command line argument thing. |
Seems that 2048 is way to high and already causes stack overflows. If just the compiler wouldn't compile forever... |
@uwap Seems surprising ... are you changing the |
Just the ExpansionConfig limit, since the session limit won't go crazy way too far. I guess 1024 is still ok for macros. It is compiling and testing right now, so I can tell you more later. |
Ah, I misunderstood you, I thought you meant the overflows were happening when compiling the compiler! You mean rather that an infinite recursion test will overflow before it hits the 2048 limit I think. |
Yes |
I got a workaround, but I guess it is not the best way. Sadly I got ill, so I won't be able to work on it further. Maybe someone else could go on? /cc @fhahn (uwap@47a78a9) |
Defining macros recursively like so
will lead rustc to cause a stack overflow.
It would be useful to improve the error message for that problem.
There is currently no error message specified for that issue.
The text was updated successfully, but these errors were encountered: