resolve: fix stack overflow on cyclic ambiguous glob reexports - #160983
Closed
calvinrp wants to merge 1 commit into
Closed
resolve: fix stack overflow on cyclic ambiguous glob reexports#160983calvinrp wants to merge 1 commit into
calvinrp wants to merge 1 commit into
Conversation
Collaborator
|
r? @camelid rustbot has assigned @camelid. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
calvinrp
force-pushed
the
fix/effective-vis-glob-cycle
branch
from
August 12, 2026 12:45
c48d854 to
e8a9bbb
Compare
`update_decl_chain` follows `ambiguity_vis_max` recursively, and ambiguous glob imports can form cyclic reexport chains, so the walk never terminated. Visit each declaration at most once per walk, and walk the crate root's bindings inside the `changed` fixpoint loop like every other module's, so any update a skipped revisit leaves behind is re-attempted until nothing changes.
calvinrp
force-pushed
the
fix/effective-vis-glob-cycle
branch
from
August 12, 2026 12:46
e8a9bbb to
bbccc30
Compare
Contributor
|
@calvinrp can you please share how you're using an LLM to author this patch? Thanks |
Contributor
Author
|
@apiraino I used Claude Fable to assist with investigating and testing the patch. I should have disclosed that upfront. I was trying to be helpful to resolve this regression quickly. |
Contributor
Author
|
I'm going to close this and revise. |
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.
Fixes #160685 (1.98 beta regression from #159039, found by the crater run).
#159039 made
update_decl_chainfollowambiguity_vis_maxrecursively, so the most visible declaration's whole reexport chain gets its effective visibility. But ambiguous glob imports can form cycles, in the minimized example two modules glob-import each other and the same item also arrives through a third, and on such a cycle the recursion never terminates, so rustc overflows its stack.Fix, two parts that belong together:
changedfixpoint loop like every other module's bindings already do. Anything a walk skips is re-attempted until nothing changes, so the final table is unchanged for code that compiled before.The minimized reproducer from the issue is added as a
check-passtest.tests/ui/{imports,privacy,resolve}pass with the #159039 regression tests unmodified, and a crate depending onreflect_tools 0.4.0(the crater trigger) compiles again.Since the regression ships in 1.98 otherwise, nominating for beta backport.
@rustbot label +A-resolve +A-visibility +T-compiler +beta-nominated