Repository navigation
fix: preserve stack space during recursive shell execution - #318
Draft
gautamsirdeshmukh wants to merge 1 commit into
Draft
gautamsirdeshmukh wants to merge 1 commit into
gautamsirdeshmukh wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Recursive shell functions can exhaust a normal worker stack before reaching the configured recursion limit. Kernel callbacks then run with too little stack. In Box, this makes Cedar report
recursion limit reachedand deny commands even when the policies are not recursive.Grow the native stack when polling or dropping recursive execution futures. Execution stays on the same thread and keeps borrowing the caller's process, with the same Tokio task locals. The configured depth limit stays in effect. WASM retains its host stack behavior.
Native execution can allocate additional 4 MiB stack segments. Allocation failure panics, and performance overhead has not been benchmarked. The guards protect recursive execution; other recursive algorithms in the crate keep their current stack behavior.
Related Issues
Related to strands-agents/staging-boxy#585. Box's diagnostic buffering and exit presentation are separate work.
Documentation PR
The runtime requirements in
src/lib.rsdescribe the native stack behavior.Type of Change
Bug fix
Testing
On macOS arm64:
The released Box 0.2.0 reproduces the policy failures with 40 recursive calls. Box built with this Shell change completes both 40 and 60 calls on its normal worker stack, with no recursion warnings or recorded internal faults.
Regression tests cover kernel callback headroom, preserved policy denials, captured execution, the configured depth limit, and cancellation of deeply nested futures.
cargo +1.98.1 xtask check --rust-onlypasses: formatting, clippy, all 2,642 Rust tests without skips, and documentation withRUSTDOCFLAGS=-D warnings. Existing lint warnings remain.Linux, Windows, Python, Node.js, and WASM were not exercised locally.
I ran the relevant test suites for the bindings I touched (
cargo test --workspace --all-targets,pytest tests/python,npm test)If I touched Rust, I ran
cargo fmtandcargo clippyChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.