Skip to content

fix(interpreter): save/restore memory_budget in subshell/cmdsub#1015

Merged
chaliy merged 1 commit intomainfrom
fix/issue-993-memory-budget-desync
Apr 2, 2026
Merged

fix(interpreter): save/restore memory_budget in subshell/cmdsub#1015
chaliy merged 1 commit intomainfrom
fix/issue-993-memory-budget-desync

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 2, 2026

Summary

  • Save and restore memory_budget alongside other state in subshell, command substitution, and script execution paths
  • Add MemoryBudget::recompute_from_state for restore_shell_state snapshot restoration
  • Prevents budget inflation (false denial of variable creation) and budget undercount (limit bypass)

Closes #993

Test plan

  • New spec tests: memory_budget_desync.test.sh with 3 cases
  • cargo test --all-features passes
  • cargo clippy -- -D warnings clean
  • cargo fmt --check clean

…substitution

Closes #993 — memory_budget was not saved/restored alongside variables,
arrays, and functions in subshell, command substitution, and script
execution paths. This caused budget desync where the budget either
inflated (preventing legitimate variable creation) or undercounted
(allowing limit bypass). Also adds recompute_from_state to MemoryBudget
for restore_shell_state snapshots.
@chaliy chaliy merged commit 9bfe855 into main Apr 2, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-993-memory-budget-desync branch April 2, 2026 14:53
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.

Memory budget desync after subshell/command-substitution state restoration

1 participant