Skip to content

Conversation

@ilonatommy
Copy link
Member

@ilonatommy ilonatommy commented Nov 4, 2025

Problem this PR is fixing

See: dotnet/runtime#121202 (comment).

Recursive canonical-closure expansion in ICU’s canonical iterator and collation importer could revisit the same substring/import chain indefinitely. With deeply nested or cyclic decompositions/imports, the iterator would overflow the stack and [import …] would spin forever (or until the host stack failed).

Fixes

  • Canonical iterator caniter.cpp: added a cycle guard. Every segment encountered during the recursive walk is tracked in a “visited” set collectEquivalentsRecursive so we stop recursing once we see the same canonical form again. Prevents runaway recursion and keeps closure generation finite.
  • Collation rule parser collationruleparser.cpp introduced importRecursionGuard, a hash table that records the [import locale/type] pairs currently being processed. If an import re-enters one of those pairs, we break out instead of chasing the loop, stopping the stack overflow. Normalized the locale/type strings before storing them, and updated the cleanup so the guard is cleared as we unwind.

Together these changes keep both canonical closure expansion and rule imports from recursing indefinitely while touching only the minimal code paths needed for the stack overflow fix.

Filters were restored to the state from before #686 and prebuilts were updated accordingly.

@ilonatommy ilonatommy self-assigned this Nov 4, 2025
@ilonatommy ilonatommy changed the title ICU 72 - prevent stack overflow when in collator ICU 72 - prevent stack overflow in collator Nov 4, 2025
@ilonatommy ilonatommy enabled auto-merge November 4, 2025 10:18
@ilonatommy ilonatommy merged commit b6c6771 into dotnet:dotnet/main Nov 4, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants