Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(execution): Canister snapshots should include Wasm globals #1250

Merged
merged 6 commits into from
Sep 3, 2024

Conversation

luc-blaeser
Copy link
Contributor

@luc-blaeser luc-blaeser commented Aug 30, 2024

Currently, the canister snapshots do not cover the state of Wasm global variables, such that in realistic canister programs with mutable global variables, the state is not properly recovered when a snapshot is loaded.

This fix adds the Wasm globals to the snapshot state, similar to the execution state. (Side note: All Wasm variables are exported by the Wasm instrumentation.)

@luc-blaeser luc-blaeser changed the title Fix(execution): Canister snapshots should include Wasm globals fix(execution): Canister snapshots should include Wasm globals Aug 30, 2024
@github-actions github-actions bot added the fix label Aug 30, 2024
Copy link
Member

@schneiderstefan schneiderstefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the same problem exists for the fields ExecutionState::exports and ExecutionState::metadata.

rs/replicated_state/src/canister_snapshots.rs Show resolved Hide resolved
@berestovskyy
Copy link
Contributor

I think the same problem exists for the fields ExecutionState::exports and ExecutionState::metadata.

Why do you think so?

@schneiderstefan
Copy link
Member

Why do you think so?

Aren't they also extracted from the wasm and should therefore be restored when the wasm is restored? I might be mistaken of course, you know that code better.

@berestovskyy
Copy link
Contributor

Aren't they also extracted from the wasm and should therefore be restored when the wasm is restored?

I believe the exports and metadata should be restored from the restored Wasm module. And I guess that's why we missed globals...

@schneiderstefan
Copy link
Member

I believe the exports and metadata should be restored from the restored Wasm module. And I guess that's why we missed globals...

I got it wrong then and it's all good.

Copy link
Contributor

@berestovskyy berestovskyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, @luc-blaeser!

@luc-blaeser luc-blaeser self-assigned this Sep 3, 2024
@luc-blaeser luc-blaeser added this pull request to the merge queue Sep 3, 2024
Merged via the queue into master with commit bd47120 Sep 3, 2024
24 checks passed
@luc-blaeser luc-blaeser deleted the luc/fix-canister-snapshots branch September 3, 2024 10:35
mergify bot pushed a commit to dfinity/motoko that referenced this pull request Sep 9, 2024
Using IC 2024-08-16 with some adjustments:
* `drun` adjustments for better testing
   - dfinity/ic#662 (Lift 8GB memory boundary from drun)
   - dfinity/ic#988 (Enable Wasm64 with 16GB main memory capacity)
   - dfinity/ic#991 (Disable DTS for deterministic debug outputs)
   - dfinity/ic#992 (Increase batch limit for longer running tests)
   - dfinity/ic#1240 (Enable canister snapshots)
* IC build fixes for `nix`:
   - Remove duplicate entries of same crate with same versions in `Cargo.toml`.
   - dfinity/ic#993 (Fix MacOS `rocksdb` dependency).
* Other IC fixes:
   - dfinity/ic#1250 (Fix canister snapshots)
levifeldman pushed a commit to levifeldman/ic that referenced this pull request Oct 1, 2024
…ty#1250)

Currently, the canister snapshots do not cover the state of Wasm global
variables, such that in realistic canister programs with mutable global
variables, the state is not properly recovered when a snapshot is
loaded.

This fix adds the Wasm globals to the snapshot state, similar to the
execution state. (Side note: All Wasm variables are exported by the Wasm
instrumentation.)
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.

4 participants