mirror of
				https://github.com/bytecodealliance/wasm-micro-runtime.git
				synced 2025-10-31 13:17:31 +00:00 
			
		
		
		
	wasm_cluster_destroy_spawned_exec_env: Avoid "invalid exec env" trap (#3068)
Possible alternatives: * Make wasm_cluster_destroy_spawned_exec_env take two exec_env. One for wasm execution and another to specify the target to destroy. * Make execute functions to switch exec_env as briefly discussed in https://github.com/bytecodealliance/wasm-micro-runtime/pull/2047
This commit is contained in:
		
							parent
							
								
									b44aa654b8
								
							
						
					
					
						commit
						ab97d543e0
					
				|  | @ -604,11 +604,24 @@ wasm_cluster_destroy_spawned_exec_env(WASMExecEnv *exec_env) | |||
|     WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env); | ||||
|     wasm_module_inst_t module_inst = wasm_runtime_get_module_inst(exec_env); | ||||
|     bh_assert(cluster != NULL); | ||||
|     WASMExecEnv *exec_env_tls = NULL; | ||||
| 
 | ||||
| #ifdef OS_ENABLE_HW_BOUND_CHECK | ||||
|     /* Note: free_aux_stack can execute the module's "free" function
 | ||||
|      * using the specified exec_env. In case of OS_ENABLE_HW_BOUND_CHECK, | ||||
|      * it needs to match the TLS exec_env if available. (Consider a native | ||||
|      * function which calls wasm_cluster_destroy_spawned_exec_env.) | ||||
|      */ | ||||
|     exec_env_tls = wasm_runtime_get_exec_env_tls(); | ||||
| #endif | ||||
|     if (exec_env_tls == NULL) { | ||||
|         exec_env_tls = exec_env; | ||||
|     } | ||||
| 
 | ||||
|     os_mutex_lock(&cluster->lock); | ||||
| 
 | ||||
|     /* Free aux stack space */ | ||||
|     free_aux_stack(exec_env, exec_env->aux_stack_bottom.bottom); | ||||
|     free_aux_stack(exec_env_tls, exec_env->aux_stack_bottom.bottom); | ||||
|     /* Remove exec_env */ | ||||
|     wasm_cluster_del_exec_env_internal(cluster, exec_env, false); | ||||
|     /* Destroy exec_env */ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 YAMAMOTO Takashi
						YAMAMOTO Takashi