Fix wasm-c-api import func link issue in wasm_instance_new (#1787)
When a wasm module is duplicated instantiated with wasm_instance_new, the function import info of the previous instantiation may be overwritten by the later instantiation, which may cause unexpected behavior. Store the function import info into the module instance to fix the issue.
This commit is contained in:
@ -192,6 +192,16 @@ typedef struct WASMExportMemInstance {
|
||||
WASMMemoryInstance *memory;
|
||||
} WASMExportMemInstance;
|
||||
|
||||
/* wasm-c-api import function info */
|
||||
typedef struct CApiFuncImport {
|
||||
/* host func pointer after linked */
|
||||
void *func_ptr_linked;
|
||||
/* whether the host func has env argument */
|
||||
bool with_env_arg;
|
||||
/* the env argument of the host func */
|
||||
void *env_arg;
|
||||
} CApiFuncImport;
|
||||
|
||||
/* Extra info of WASM module instance for interpreter/jit mode */
|
||||
typedef struct WASMModuleInstanceExtra {
|
||||
WASMGlobalInstance *globals;
|
||||
@ -205,6 +215,8 @@ typedef struct WASMModuleInstanceExtra {
|
||||
WASMFunctionInstance *free_function;
|
||||
WASMFunctionInstance *retain_function;
|
||||
|
||||
CApiFuncImport *c_api_func_imports;
|
||||
|
||||
#if WASM_ENABLE_SHARED_MEMORY != 0
|
||||
/* lock for shared memory atomic operations */
|
||||
korp_mutex mem_lock;
|
||||
|
||||
Reference in New Issue
Block a user