Skip to content

Prevent infinite recursion and OOM in project_and_unify_term#156842

Open
BloodStainedCrow wants to merge 1 commit into
rust-lang:mainfrom
BloodStainedCrow:issue-156615-fix
Open

Prevent infinite recursion and OOM in project_and_unify_term#156842
BloodStainedCrow wants to merge 1 commit into
rust-lang:mainfrom
BloodStainedCrow:issue-156615-fix

Conversation

@BloodStainedCrow
Copy link
Copy Markdown

@BloodStainedCrow BloodStainedCrow commented May 22, 2026

Prevents an infinite recursion when using the old trait solver.

Fixes #156615.

Note that the example in #156615 encounters this infinite recursion in report_ambiguity_errors.
The overflow abort introduced here shadows the original error for which we are generating a report, which is unfortunate but preferable to hangs/OOMs:

# Notably no info about "type ambiguity"
error[E0275]: overflow evaluating the requirement `<Family as DistributionFamily>::Distribution<_> == _`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0275`.

Ideally, we could report the original error AND report the overflow while generating the report, something like this:

error[E0283]: type annotations needed
  --> non-termination-while-reporting-ambiguity-error-issue-1156615.rs:28:10
  --> error: overflow evaluating the requirement `<Family as DistributionFamily>::Distribution<_> == _` while generating error report

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 22, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 22, 2026

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 19 candidates

@BloodStainedCrow BloodStainedCrow changed the title Prevent infinite recursion and OOM in project_and_unify_term Prevent infinite recursion and OOM in project_and_unify_term May 22, 2026
@BloodStainedCrow
Copy link
Copy Markdown
Author

BloodStainedCrow commented May 22, 2026

I have added the recursion check to the "lowest" function which added the new obligation,
according to this comment "process_projection_obligation should do its own recursion depth checking" but from what I can tell, nothing in there does any checking? Is that intentional?

So it might make sense to move this check further up to cover more of process_projection_obligation but I do not have enough understanding of the type checking being done here to know which functions could theoretically recurse infinitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switching to Family-Pattern results in compiler non-termination in report_ambiguity_errors

3 participants