Skip to content

Avoid stack overflow on drop of deep AST#479

Open
samuelcolvin wants to merge 1 commit into
mainfrom
drop-bomb
Open

Avoid stack overflow on drop of deep AST#479
samuelcolvin wants to merge 1 commit into
mainfrom
drop-bomb

Conversation

@samuelcolvin

@samuelcolvin samuelcolvin commented May 30, 2026

Copy link
Copy Markdown
Member

uses #25480

Summary by cubic

Prevents stack overflow when dropping very deep Python ASTs by severing recursive edges before drop. Deeply nested expressions now return a safe “Source is too deeply nested” error instead of crashing.

  • Bug Fixes

    • Avoid recursive drops by using mem::replace on BinOp, Call, Subscript, and Attribute, with placeholders to vacate owned fields.
    • Added helpers: deconstruct_subscript, deconstruct_attribute, placeholder_expr, placeholder_arguments.
    • Added many_plus test to stress deep binary chains; both this and deep attribute access now fail safely with the expected error.
  • Dependencies

    • Bumped ruff_* and ty_* crates (e.g., ruff_python_parser, ruff_python_ast, ruff_text_size, ruff_db, ty_python_semantic, ty_python_core, ty_module_resolver, ty_vendored) to the latest revision.

Written for commit 8d0092d. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 4 files

Re-trigger cubic

@codspeed-hq

codspeed-hq Bot commented May 30, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 17 untouched benchmarks
⏩ 15 skipped benchmarks1


Comparing drop-bomb (8d0092d) with main (4cae078)

Open in CodSpeed

Footnotes

  1. 15 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.

@github-actions

Copy link
Copy Markdown

Codecov Results 📊

❌ Patch coverage is 77.05%. Project has 24059 uncovered lines.
✅ Project coverage is 66.39%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
crates/monty/src/parse.rs 77.05% ⚠️ 14 Missing and 3 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    66.36%    66.39%    +0.03%
==========================================
  Files          281       281         —
  Lines        71521     71573       +52
  Branches    153638    153776      +138
==========================================
+ Hits         47460     47514       +54
- Misses       24061     24059        -2
- Partials      4067      4066        -1

Generated by Codecov Action

@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.16393% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/monty/src/parse.rs 90.16% 0 Missing and 6 partials ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant