Skip to content

fix: enforce type depth/size limits on PackClosure function types - #407

Open
0xIcarus wants to merge 1 commit into
m1from
0xicarus/fix-closure-type-depth-accounting
Open

fix: enforce type depth/size limits on PackClosure function types#407
0xIcarus wants to merge 1 commit into
m1from
0xicarus/fix-closure-type-depth-accounting

Conversation

@0xIcarus

@0xIcarus 0xIcarus commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Description

PackClosure was constructing Type::Function directly, skipping the TypeBuilder depth and size checks that all other composite types go through. A deeply nested or oversized closure type could be pushed onto the operand stack unchecked.

Added TypeBuilder::create_function_ty and routed PackClosure through it. No version gate needed. Closures are already behind ENABLE_FUNCTION_VALUES

How Has This Been Tested?

  • test_create_function_ty_depth: verifies depth-5 result type is rejected, depth-4 passes
  • test_create_function_ty_size: verifies 5 Bool args is rejected, 4 passes (node count = max)

Key Areas to Review

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@blacksmith-sh

blacksmith-sh Bot commented Jul 30, 2026

Copy link
Copy Markdown

Found 3 test failures on Blacksmith runners:

Failures

Test View Logs
move-compiler-v2-transactional-tests::tests/compiler-v2-txn[config=baseline]::tests/
no-v1-comparison/closures/misc_1.move
View Logs
move-compiler-v2-transactional-tests::tests/compiler-v2-txn[config=no-optimize]::tests/
no-v1-comparison/closures/misc_1.move
View Logs
move-compiler-v2-transactional-tests::tests/compiler-v2-txn[config=optimize]::tests/
no-v1-comparison/closures/misc_1.move
View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

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