From 1ff04a912513f23c7f7ec977ca6f07f02c90f7a9 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Fri, 23 Sep 2022 09:31:44 +0800 Subject: [PATCH] Fix issue in wasm/aot enlarge memory (#1512) Memory num_bytes_per_page was incorrectly set in memory enlarging for shared memory, we fix it. And don't set memory_data_size again for shared memory. --- core/iwasm/aot/aot_runtime.c | 6 ++++-- core/iwasm/interpreter/wasm_runtime.c | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 0fd805f9..6213bce1 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -2097,10 +2097,12 @@ aot_enlarge_memory(AOTModuleInstance *module_inst, uint32 inc_page_count) #if WASM_ENABLE_SHARED_MEMORY != 0 if (memory->is_shared) { - memory->num_bytes_per_page = UINT32_MAX; + memory->num_bytes_per_page = num_bytes_per_page; memory->cur_page_count = total_page_count; memory->max_page_count = max_page_count; - memory->memory_data_size = (uint32)total_size_new; + /* No need to update memory->memory_data_size as it is + initialized with the maximum memory data size for + shared memory */ return true; } #endif diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 669852a5..db8eccb7 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -2507,9 +2507,12 @@ wasm_enlarge_memory(WASMModuleInstance *module, uint32 inc_page_count) #if WASM_ENABLE_SHARED_MEMORY != 0 if (memory->is_shared) { - memory->num_bytes_per_page = UINT32_MAX; + memory->num_bytes_per_page = num_bytes_per_page; memory->cur_page_count = total_page_count; memory->max_page_count = max_page_count; + /* No need to update memory->memory_data_size as it is + initialized with the maximum memory data size for + shared memory */ return true; } #endif