Repository navigation
test: panics when growing WASM memory - #10783
Merged
Merged
Conversation
The system test loaded a 2 MiB snapshot heap into a `(memory 1 1)` module, which cannot grow to the snapshot's 32 pages, so `inc` fails gracefully with IC0521. Assert the graceful failure (mirroring the unit test) instead of expecting the call to succeed. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Assert the exact IC0521 (CanisterWasmEngineError) error message in the two graceful-failure unit tests instead of a bare is_err(). Also fix pre-existing clippy lints in both test files (unseparated_literal_suffix on integer literals and needless_borrows_for_generic_args on the wat::parse_str arguments). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds regression tests to ensure canister snapshot loading/upgrade paths fail with a proper wasm-engine error (rather than panicking) when the snapshot/retained heap requires growing Wasm memory beyond a module’s declared maximum.
Changes:
- Add a new end-to-end system test that uploads a snapshot with a larger declared
wasm_memory_sizethan the module’s(memory 1 1)max and verifies the ensuing call fails. - Add two state-machine unit tests covering (1) snapshot load with oversized wasm memory and (2) upgrade with
wasm_memory_persistence: Keepwhere the retained heap exceeds the new module max. - Wire the new system test module into the general execution test suite.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| rs/tests/execution/general_execution_tests/mod.rs | Exposes the new canister_snapshots system-test module. |
| rs/tests/execution/general_execution_tests/canister_snapshots.rs | Adds an end-to-end snapshot upload/load test intended to catch prior embedder panics when memory growth exceeds module max. |
| rs/tests/execution/general_execution_test.rs | Registers the new system test in the execution test runner. |
| rs/execution_environment/tests/canister_snapshots.rs | Adds state-machine regression tests asserting specific wasm-engine error behavior for snapshot load and upgrade-with-keep scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
✅ No security or compliance issues detected. Reviewed everything up to 7ff5d05. Security OverviewDetected Code Changes
|
schneiderstefan
approved these changes
Jul 16, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jul 16, 2026
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.
This PR implements regression tests for this PR.
Unit tests (
rs/execution_environment/tests/canister_snapshots.rs):upload_and_load_snapshot_with_wasm_memory— Uploads a snapshot declaring 2 MiB (32 pages) of wasm memory for a(memory 1 1)module, loads it, and asserts inc fails gracefully (the1-page max can't grow to 32).
upgrade_with_keep_heap_exceeds_module_max_fails_gracefully— Installs a 20-page module with orthogonal persistence, upgrades to(memory 1 1)withwasm_memory_persistence: Keep,and asserts the retained 20-page heap exceeding the new 1-page max fails gracefully.
System test (
rs/tests/execution/general_execution_tests/canister_snapshots.rs):3.
upload_and_load_snapshot_with_wasm_memory— The end-to-end mirror of unit test #1: same setup driven over the public API against an application subnet (heap uploaded in 1 MiBchunks), asserting inc fails gracefully rather than panicking the replica.
All three exercise the same code path — the embedder returning
IC0521 ("Failed to grow wasm memory … exceeds module's declared maximum")instead of the old.expect("memory grow failed")panic.