Skip to content

Avoid stack overflows in resolver error reporting#19684

Closed
charliermarsh wants to merge 8 commits into
mainfrom
charlie/fix-resolver-stack-overflow
Closed

Avoid stack overflows in resolver error reporting#19684
charliermarsh wants to merge 8 commits into
mainfrom
charlie/fix-resolver-stack-overflow

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

Prior to this change, resolving an unsatisfiable dependency graph with many candidate versions could overflow the process stack while constructing and displaying the resolver error.

This PR makes derivation-tree error handling stack-safe by growing the stack during recursive transformations, hint generation, debugging, and report formatting. Tree traversal and destruction use iterative implementations where possible (avoiding another overflow when large intermediate trees are inspected or dropped).

Since PubGrub's recursive reporting entry point is private, we mirror its reporter for now while preserving its output and shared-node references.

Closes #19672.

@charliermarsh charliermarsh added the bug Something isn't working label Jun 5, 2026
@charliermarsh

Copy link
Copy Markdown
Member Author

I'm going to look at avoiding recursion altogether too.

@charliermarsh charliermarsh requested a review from konstin June 5, 2026 19:06
@charliermarsh charliermarsh marked this pull request as ready for review June 5, 2026 19:06
@charliermarsh charliermarsh force-pushed the charlie/fix-resolver-stack-overflow branch 3 times, most recently from adb03ae to 46bb603 Compare June 5, 2026 19:53
@charliermarsh charliermarsh marked this pull request as draft June 5, 2026 20:55
charliermarsh added a commit that referenced this pull request Jun 7, 2026
## Summary

Prior to this change, resolving an unsatisfiable dependency graph with
many candidate versions could overflow the process stack while
constructing, reducing, formatting, or dropping the resolver error.

This PR is an alternative to #19684. That PR retains the recursive
derivation-tree algorithms and uses `stacker::maybe_grow` before
recursive descent, while making ownership-sensitive destruction and
selected traversals iterative. This PR instead removes recursion from
every derivation-tree path: transformations and reductions use explicit
post-order work stacks. (The tradeoff is a larger implementation with
more explicit traversal state, but we avoid the `stacker` dependency,
which also doesn't seem to work on all of our supported platforms.)

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv-resolver stack overflow

1 participant