fix(linter): fix stack overflow in no-unreachable rule on large files#18077
fix(linter): fix stack overflow in no-unreachable rule on large files#18077graphite-app[bot] merged 1 commit intomainfrom
no-unreachable rule on large files#18077Conversation
There was a problem hiding this comment.
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_searchfunction incrates/oxc_cfg/src/visit.rsfrom a recursive to an iterative implementation using an explicit stack - Updated
no-unreachablerule to importset_depth_first_searchinstead of petgraph'sdepth_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.
d43b929 to
544e353
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
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)
544e353 to
2aae4fc
Compare
Summary
set_depth_first_searchinoxc_cfgfrom recursive to iterative implementation using an explicit stackno-unreachablerule to use the iterative DFS instead of petgraph's recursivedepth_first_searchThis fixes stack overflow when linting large files with many basic blocks in the control flow graph.
Closes #11250
Test plan
RUST_MIN_STACK=262144 ./target/debug/oxlint -A all -D no-unreachable large_file.js🤖 Generated with Claude Code