Test restoring zeroed data (#9011)

* Test restoring zeroed data

* Change to u64
This commit is contained in:
Sergei Shulepov
2021-06-15 11:58:09 +01:00
committed by GitHub
parent 3df32a5411
commit 5f0257f3b3
2 changed files with 34 additions and 0 deletions
@@ -588,6 +588,25 @@ fn returns_mutable_static(wasm_method: WasmExecutionMethod) {
assert_eq!(33, u64::decode(&mut &res[..]).unwrap());
}
test_wasm_execution!(returns_mutable_static_bss);
fn returns_mutable_static_bss(wasm_method: WasmExecutionMethod) {
let runtime = mk_test_runtime(wasm_method, 1024);
let instance = runtime.new_instance().unwrap();
let res = instance
.call_export("returns_mutable_static_bss", &[0])
.unwrap();
assert_eq!(1, u64::decode(&mut &res[..]).unwrap());
// We expect that every invocation will need to return the initial
// value plus one. If the value increases more than that then it is
// a sign that the wasm runtime preserves the memory content.
let res = instance
.call_export("returns_mutable_static_bss", &[0])
.unwrap();
assert_eq!(1, u64::decode(&mut &res[..]).unwrap());
}
// If we didn't restore the wasm instance properly, on a trap the stack pointer would not be
// returned to its initial value and thus the stack space is going to be leaked.
//