Skip to content

chore: turn some embedder panics into errors - #10593

Merged
mraszyk merged 1 commit into
masterfrom
mraszyk/embedder-errors
Jun 29, 2026
Merged

mraszyk merged 1 commit into
masterfrom
mraszyk/embedder-errors

Conversation

@mraszyk

@mraszyk mraszyk commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

This PR turns some embedder panics into errors. The motivation for this change is defense-in-depth - an error has a smaller blast radius.

@github-actions github-actions Bot added the chore label Jun 29, 2026
@mraszyk
mraszyk marked this pull request as ready for review June 29, 2026 08:51
@mraszyk
mraszyk requested a review from a team as a code owner June 29, 2026 08:51
@mraszyk
mraszyk added this pull request to the merge queue Jun 29, 2026
@zeropath-ai

zeropath-ai Bot commented Jun 29, 2026

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed everything up to 7418071.

Security Overview
Detected Code Changes
Change Type Relevant files
Bug Fix ► wasmtime_embedder.rs
    Handle errors during global variable setting in Wasmtime embedder
    Return specific error for failed Wasm memory growth in Wasmtime embedder
Refactor ► wasmtime_embedder.rs
    Improve error handling for Wasm instantiation in Wasmtime embedder

Merged via the queue into master with commit 34009aa Jun 29, 2026
41 checks passed
@mraszyk
mraszyk deleted the mraszyk/embedder-errors branch June 29, 2026 09:18
pull Bot pushed a commit to mikeyhodl/ic that referenced this pull request Jul 16, 2026
This PR implements regression tests for this
[PR](dfinity#10593).

  Unit tests (`rs/execution_environment/tests/canister_snapshots.rs`):
1. `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 (the
  1-page max can't grow to 32).
2. `upgrade_with_keep_heap_exceeds_module_max_fails_gracefully` —
Installs a 20-page module with orthogonal persistence, upgrades to
`(memory 1 1)` with `wasm_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 MiB
chunks), 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.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants