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
@@ -39,6 +39,14 @@ extern "C" {
/// the initialized value at the start of a runtime call.
static mut MUTABLE_STATIC: u64 = 32;
#[cfg(not(feature = "std"))]
/// This is similar to `MUTABLE_STATIC`. The tests need `MUTABLE_STATIC` for testing that
/// non-null initialization data is properly restored during instance reusing.
///
/// `MUTABLE_STATIC_BSS` on the other hand focuses on the zeroed data. This is important since there
/// may be differences in handling zeroed and non-zeroed data.
static mut MUTABLE_STATIC_BSS: u64 = 0;
sp_core::wasm_export_functions! {
fn test_calling_missing_external() {
unsafe { missing_external() }
@@ -309,6 +317,13 @@ sp_core::wasm_export_functions! {
}
}
fn returns_mutable_static_bss() -> u64 {
unsafe {
MUTABLE_STATIC_BSS += 1;
MUTABLE_STATIC_BSS
}
}
fn allocates_huge_stack_array(trap: bool) -> Vec<u8> {
// Allocate a stack frame that is approx. 75% of the stack (assuming it is 1MB).
// This will just decrease (stacks in wasm32-u-u grow downwards) the stack