Skip to content

fix(linter): fix stack overflow in no-unreachable rule on large files#18077

Merged
graphite-app[bot] merged 1 commit intomainfrom
fix/no-unreachable-stack-overflow
Jan 16, 2026
Merged

fix(linter): fix stack overflow in no-unreachable rule on large files#18077
graphite-app[bot] merged 1 commit intomainfrom
fix/no-unreachable-stack-overflow

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Jan 16, 2026

Summary

  • Convert set_depth_first_search in oxc_cfg from recursive to iterative implementation using an explicit stack
  • Update no-unreachable rule to use the iterative DFS instead of petgraph's recursive depth_first_search

This fixes stack overflow when linting large files with many basic blocks in the control flow graph.

Closes #11250

Test plan

  • All 916 linter tests pass
  • Verified fix with reduced stack size: RUST_MIN_STACK=262144 ./target/debug/oxlint -A all -D no-unreachable large_file.js
  • Also tested with 128KB stack size successfully

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings January 16, 2026 11:54
@Boshen Boshen requested a review from camc314 as a code owner January 16, 2026 11:54
@github-actions github-actions bot added A-linter Area - Linter A-cfg Area - Control Flow Graph C-bug Category - Bug labels Jan 16, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a stack overflow issue in the no-unreachable linter rule when processing large files by converting the depth-first search implementation from recursive to iterative.

Changes:

  • Converted set_depth_first_search function in crates/oxc_cfg/src/visit.rs from a recursive to an iterative implementation using an explicit stack
  • Updated no-unreachable rule to import set_depth_first_search instead of petgraph's depth_first_search

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/oxc_linter/src/rules/eslint/no_unreachable.rs Updated imports to use the iterative set_depth_first_search implementation
crates/oxc_cfg/src/visit.rs Replaced recursive DFS with iterative implementation using explicit stack to prevent stack overflow

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Boshen Boshen force-pushed the fix/no-unreachable-stack-overflow branch 2 times, most recently from d43b929 to 544e353 Compare January 16, 2026 12:01
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 16, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 41 skipped benchmarks1


Comparing fix/no-unreachable-stack-overflow (544e353) with main (b516088)2

Open in CodSpeed

Footnotes

  1. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (40ef7ee) during the generation of this report, so b516088 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Jan 16, 2026
Copy link
Contributor

camc314 commented Jan 16, 2026

Merge activity

…es (#18077)

## Summary

- Convert `set_depth_first_search` in `oxc_cfg` from recursive to iterative implementation using an explicit stack
- Update `no-unreachable` rule to use the iterative DFS instead of petgraph's recursive `depth_first_search`

This fixes stack overflow when linting large files with many basic blocks in the control flow graph.

Closes #11250

## Test plan

- [x] All 916 linter tests pass
- [x] Verified fix with reduced stack size: `RUST_MIN_STACK=262144 ./target/debug/oxlint -A all -D no-unreachable large_file.js`
- [x] Also tested with 128KB stack size successfully

🤖 Generated with [Claude Code](https://claude.ai/code)
@graphite-app graphite-app bot force-pushed the fix/no-unreachable-stack-overflow branch from 544e353 to 2aae4fc Compare January 16, 2026 12:33
@graphite-app graphite-app bot merged commit 2aae4fc into main Jan 16, 2026
21 checks passed
@graphite-app graphite-app bot deleted the fix/no-unreachable-stack-overflow branch January 16, 2026 12:39
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cfg Area - Control Flow Graph A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: panic in no-unreachable on large files

3 participants