fix(sierra-to-casm): prevent wide frame offset overflow - #10374
DicksonWu654 wants to merge 2 commits into
Conversation
PR SummaryMedium Risk Overview Frame walking now accumulates offsets in Adds boundary tests for wide parameters and wide multi-output returns, including overflow and stack-contiguity cases. Reviewed by Cursor Bugbot for commit dfac89b. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on DicksonWu654).
a discussion (no related file):
Rather not extend the supported sierra programs without specific reason.
the i16 overflow is a valid failure for using the program.
Summary
Prevent valid wide Sierra function parameter and return layouts from panicking during Sierra-to-CASM reference construction. Frame layout now uses wider signed arithmetic, converts each final CASM offset to
i16with a checked conversion, and returns existing structured compilation errors when an offset is not encodable.Type of change
Why is this change needed?
A valid 32,766-cell function parameter frame reaches offset
fp - 32768, but the previousi16expression computed an out-of-range intermediate before adding one. Function-call return construction and stack-contiguity validation had symmetric intermediate or sentinel underflows. With overflow checks enabled these layouts panic even though every emitted reference offset is representable.What was the behavior or documentation before?
Wide but representable parameter and return layouts could panic while constructing or validating reference expressions.
What is the behavior or documentation after?
Frame offsets are accumulated in
i64; final dereference offsets are checked when converted toi16. Representable boundary layouts compile normally, while layouts outside the CASM offset range produce structured errors. Regression coverage exercises the exact parameter and function-call return boundaries, including output ordering and full-width stack validation.Related issue or discussion (if any)
None.
Additional context
Validation performed on
sierra-minor-update:./scripts/rust_fmt.sh./scripts/rust_fmt.sh --checkRUSTUP_TOOLCHAIN=nightly-2024-08-22 cargo test -p cairo-lang-sierra-to-casm wide_(2 passed)RUSTUP_TOOLCHAIN=nightly-2024-08-22 cargo test -p cairo-lang-sierra-to-casm invocations::function_call::tests(2 passed)git diff --check origin/sierra-minor-update...HEAD