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:
@ -96,6 +96,9 @@ thread_spawn_wrapper(wasm_exec_env_t exec_env, uint32 start_arg)
|
||||
wasm_runtime_set_custom_data_internal(
|
||||
new_module_inst, wasm_runtime_get_custom_data(module_inst));
|
||||
|
||||
if (!(wasm_cluster_dup_c_api_imports(new_module_inst, module_inst)))
|
||||
goto thread_preparation_fail;
|
||||
|
||||
#if WASM_ENABLE_LIBC_WASI != 0
|
||||
wasi_ctx = wasm_runtime_get_wasi_ctx(module_inst);
|
||||
if (wasi_ctx)
|
||||
|
||||
Reference in New Issue
Block a user