Fix three multi-threading and wasm-c-api-imports issues (#2173)

Fix issue reported in #2172: wasm-c-api `wasm_func_call` may use a wrong exec_env
when multi-threading is enabled, with error "invalid exec env" reported

Fix issue reported in #2149: main instance's `c_api_func_imports` are not passed to
the counterpart of new thread's instance in wasi-threads mode

Fix issue of invalid size calculated to copy `c_api_func_imports` in pthread mode

And refactor the code to use `wasm_cluster_dup_c_api_imports` to copy the
`c_api_func_imports` to new thread for wasi-threads mode and pthread mode.
This commit is contained in:
Christof Petig
2023-05-05 04:01:58 +02:00
committed by GitHub
parent 71d43f3ca1
commit 5a23ae465c
5 changed files with 73 additions and 40 deletions

View File

@ -74,6 +74,11 @@ wasm_cluster_destroy(WASMCluster *cluster);
WASMCluster *
wasm_exec_env_get_cluster(WASMExecEnv *exec_env);
/* Forward registered functions to a new thread */
bool
wasm_cluster_dup_c_api_imports(WASMModuleInstanceCommon *module_inst_dst,
const WASMModuleInstanceCommon *module_inst_src);
int32
wasm_cluster_create_thread(WASMExecEnv *exec_env,
wasm_module_inst_t module_inst, bool alloc_aux_stack,