Skip to content

Commit 1ff04a9

Browse files
authored
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.
1 parent 78b5c5b commit 1ff04a9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

core/iwasm/aot/aot_runtime.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,10 +2097,12 @@ aot_enlarge_memory(AOTModuleInstance *module_inst, uint32 inc_page_count)
20972097

20982098
#if WASM_ENABLE_SHARED_MEMORY != 0
20992099
if (memory->is_shared) {
2100-
memory->num_bytes_per_page = UINT32_MAX;
2100+
memory->num_bytes_per_page = num_bytes_per_page;
21012101
memory->cur_page_count = total_page_count;
21022102
memory->max_page_count = max_page_count;
2103-
memory->memory_data_size = (uint32)total_size_new;
2103+
/* No need to update memory->memory_data_size as it is
2104+
initialized with the maximum memory data size for
2105+
shared memory */
21042106
return true;
21052107
}
21062108
#endif

core/iwasm/interpreter/wasm_runtime.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2507,9 +2507,12 @@ wasm_enlarge_memory(WASMModuleInstance *module, uint32 inc_page_count)
25072507

25082508
#if WASM_ENABLE_SHARED_MEMORY != 0
25092509
if (memory->is_shared) {
2510-
memory->num_bytes_per_page = UINT32_MAX;
2510+
memory->num_bytes_per_page = num_bytes_per_page;
25112511
memory->cur_page_count = total_page_count;
25122512
memory->max_page_count = max_page_count;
2513+
/* No need to update memory->memory_data_size as it is
2514+
initialized with the maximum memory data size for
2515+
shared memory */
25132516
return true;
25142517
}
25152518
#endif

0 commit comments

Comments
 (0)