Skip to content

fix: prevent stack overflow from cyclic reference resolution#794

Merged
crowlKats merged 1 commit into
mainfrom
fix-search-index-ref-cycle
Apr 15, 2026
Merged

fix: prevent stack overflow from cyclic reference resolution#794
crowlKats merged 1 commit into
mainfrom
fix-search-index-ref-cycle

Conversation

@crowlKats

Copy link
Copy Markdown
Member

Summary

  • partitioner_inner in src/html/partition.rs (used by create_partitioner and flatten_namespace) follows reference_def() targets recursively with no cycle detection. Cyclic re-exports (e.g. A references B which references A) recurse forever and overflow the stack — reproduced as a tokio-runtime-worker has overflowed its stack abort inside generate_search_index.
  • Threaded a HashSet<Location> through both recursive functions; a reference target already in progress is skipped, and is removed on unwind so sibling branches can still resolve it.

Test plan

  • cargo build
  • cargo test — 155 tests pass

Cyclic reference targets (e.g. re-exports where A → B → A) caused
`partitioner_inner` to recurse forever and blow the stack during
`generate_search_index` / namespace flattening. Thread a visited-set
through both recursions so a target in progress is not re-entered.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@piscisaureus piscisaureus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crowlKats crowlKats merged commit c565e93 into main Apr 15, 2026
7 checks passed
@crowlKats crowlKats deleted the fix-search-index-ref-cycle branch April 15, 2026 23:14
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