Skip to content

fix: validate deep binary expressions iteratively#6805

Open
martinfrancois wants to merge 1 commit into
INRIA:masterfrom
martinfrancois:agent/issue-6804-deep-binary-validation
Open

fix: validate deep binary expressions iteratively#6805
martinfrancois wants to merge 1 commit into
INRIA:masterfrom
martinfrancois:agent/issue-6804-deep-binary-validation

Conversation

@martinfrancois

@martinfrancois martinfrancois commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Process very deep binary-expression trees without overflowing the JVM stack.

Fixes #6804.

Problem

OpenJDK's valid DeepStringConcat.java contains about 32,000 binary operators in one expression. Spoon recursively visited one operator per JVM frame. It first overflowed while checking parent links and then overflowed while running processors.

Change

  • Use an explicit stack when the concrete parent checker visits consecutive binary operands.
  • Use the same approach in the concrete processing visitor.
  • Preserve Spoon's existing child order and callbacks before and after each child.
  • Preserve the normal recursive behavior for subclasses that override scanner hooks.
  • Avoid recursive pretty-printing while reporting malformed parent links.
  • Restore the parent checker's previous root state after a direct accept call.

Validation

  • Added deep-tree tests for parent checking and processor traversal.
  • Added tests for child order, synchronous hooks, subclass overrides, malformed-tree diagnostics, and repeated checker use.
  • mvn -q -Dtest=spoon.reflect.visitor.AstParentConsistencyCheckerTest,spoon.support.visitor.ProcessingVisitorTest,spoon.FluentLauncherTest test passes all 12 tests.
  • mvn -q -Dtest=spoon.test.architecture.SpoonArchitectureEnforcerTest test passes all 9 tests. The two focused commands therefore run 21 tests in total.
  • StoneDetector processes OpenJDK's DeepStringConcat.java: exit 0, AST 1/1, and no reported errors.
  • All 14 GitHub checks pass, including the Java 17, 21, and 25 test matrix, coverage, Javadoc quality, code generation, reproducibility, Qodana, and QDJVM.

@martinfrancois
martinfrancois force-pushed the agent/issue-6804-deep-binary-validation branch 2 times, most recently from 5940010 to 012fcef Compare July 17, 2026 19:01
@martinfrancois
martinfrancois marked this pull request as ready for review July 17, 2026 19:12
@martinfrancois
martinfrancois force-pushed the agent/issue-6804-deep-binary-validation branch from 012fcef to d37d694 Compare July 17, 2026 20:12
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.

[Bug]: Deep binary expressions overflow Spoon visitors

1 participant