Fix repeatedly initialize shared memory data and protect the memory's fields (#2673)

Avoid repeatedly initializing the shared memory data when creating the child
thread in lib-pthread or lib-wasi-threads.

Add shared memory lock when accessing some fields of the memory instance
if the memory instance is shared.

Init shared memory's memory_data_size/memory_data_end fields according to
the current page count but not max page count.

Add wasm_runtime_set_mem_bound_check_bytes, and refine the error message
when shared memory flag is found but the feature isn't enabled.
This commit is contained in:
Wenyong Huang
2023-10-30 11:07:01 +08:00
committed by GitHub
parent 51a6b069d2
commit 4b1a6e5017
8 changed files with 195 additions and 110 deletions

View File

@ -3038,7 +3038,8 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
}
}
strncpy(mapping_copy, map_dir_list[i], strlen(map_dir_list[i]) + 1);
bh_memcpy_s(mapping_copy, max_len, map_dir_list[i],
(uint32)(strlen(map_dir_list[i]) + 1));
map_mapped = strtok(mapping_copy, "::");
map_host = strtok(NULL, "::");