Limit obligation processing depth#153338
Open
Voultapher wants to merge 1 commit intorust-lang:mainfrom
Open
Conversation
Related to rust-lang#152857 It's possible for `ObligationForest::process_cycles` to miss more complex cycles and this can lead to an endless fixpoint loop since it never reaches a settled state. It's desirable to adjust `find_cycles_from_node` to catch the cycle in rust-lang#152857. At the same time the nature of the code risks an endless loop by some other unexpected or unhandled cycle, so this PR aims to provide a basic limit to the depth of the loop. The value of the constant was derived to be ~20x the highest value seen when compiling rustc itself. The top values are: ``` ┌───────┐ │ 10852 │ │ 10852 │ │ 10433 │ │ 10433 │ │ 10433 │ │ 10433 │ │ 8498 │ │ 8498 │ │ 6361 │ │ 6361 │ └───────┘ ```
Collaborator
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Voultapher
commented
Mar 3, 2026
| // It's possible for nodes to recursively add obligations in an endless cycle, | ||
| // for example https://github.com/rust-lang/rust/issues/152857. | ||
| self.error_at(index); | ||
| return outcome; |
Contributor
Author
There was a problem hiding this comment.
Currently this creates an ICE, which strictly speaking is still preferable to an endless loop but I'd prefer to issue a better error something similar to the other overflow errors, but not sure what's the best way to do that here.
Member
|
@rustbot reroll |
Member
Contributor
|
Does it add new obligations at each step in the cycle? If so, we should make sure that we increase the |
Contributor
|
r? lcnr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #152857
It's possible for
ObligationForest::process_cyclesto miss more complex cycles and this can lead to an endless fixpoint loop since it never reaches a settled state. It's desirable to adjustfind_cycles_from_nodeto catch the cycle in#152857. At the same time the nature of the code risks an endless loop by some other unexpected or unhandled cycle, so this PR aims to provide a basic limit to the depth of the loop.
The value of the constant was derived to be ~20x the highest value seen when compiling rustc itself. The top 10 values out of ~70 million invocations are: