-
Notifications
You must be signed in to change notification settings - Fork 13.3k
nested const-eval queries don't have a recursion limit or timeout, causing the compiler to freeze in an infinite loop #125718
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
NB: This only affects polymorphically recursive calls (i.e., calls where the generic args change at each step). Normal recursive calls lead to cycle errors. |
Hmm... The immediate solution I can come up with is to use the recursion limit to limit query depth, but that's going to be hard to tune to a good value without breaking random crates (most likely binary crates that we don't see on crater). |
That would also solve #114192. |
I think there might be something else going on here. If I try to compile this reproducer I get a freeze with growing memory usage, which is what I would expect. But if I try to ctrl-c the process, I... get a segfault?
|
It probably tries to run the Ctrl-C handler and emit a mir interpreter backtrace, but that logic doesn't use |
The original code now segfaults on playground's nightly (2024-07-12 c6727fc). However, I am unable to reproduce the segfault on my computer. @rustbot label +I-crash +regression-untriaged
|
WG-prioritization assigning priority (Zulip discussion). The infinite loop started in 1.78. Before, it just emits a error:
@rustbot label -I-prioritize +P-medium -regression-untriaged +regression-from-stable-to-stable |
That is the release that stabilized const blocks. I assume the infinite loop also happened before if you enable the nightly feature. So it's not really a regression, const blocks always behaved like this. |
… r=<try> Depth limit const eval query Currently the const-eval query doesn't have a recursion limit or timeout, causing the complier to freeze in an infinite loop, see rust-lang#125718. This PR depth limits the `eval_to_const_value_raw` query (with the [`recursion_limit`](https://doc.rust-lang.org/reference/attributes/limits.html) attribute) and improves the diagnostics for query overflow errors, so spans are reported for other dep kinds than `layout_of` (e.g. `eval_to_const_value_raw`). fixes rust-lang#125718 fixes rust-lang#114192
The above code causes the compiler to hang, apparently in an infinite loop. I expected it to report an error due to a recursion limit or a timeout.
Note that removing the const block causes the compiler to correctly report an error.
Code without the const block
This code results in the following error:
Changing the infinite recursion into an infinite loop correctly causes a timeout.
Code with an infinite loop instead of an infinite recursion
This code results in the following error:
See also #125713
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: