mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-15 08:48:33 +00:00
thread mgr: Free aux stack only when it was allocated
This commit is contained in:
parent
202abc1937
commit
65bfa8dfe4
|
@ -117,6 +117,9 @@ typedef struct WASMExecEnv {
|
|||
|
||||
/* whether current thread is detached */
|
||||
bool thread_is_detached;
|
||||
|
||||
/* whether the aux stack is allocated */
|
||||
bool is_aux_stack_allocated;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_GC != 0
|
||||
|
|
|
@ -526,6 +526,7 @@ wasm_cluster_spawn_exec_env(WASMExecEnv *exec_env)
|
|||
"failed to allocate aux stack space for new thread");
|
||||
goto fail1;
|
||||
}
|
||||
exec_env->is_aux_stack_allocated = true;
|
||||
|
||||
os_mutex_lock(&cluster->lock);
|
||||
|
||||
|
@ -603,7 +604,9 @@ wasm_cluster_destroy_spawned_exec_env(WASMExecEnv *exec_env)
|
|||
exec_env_tls = exec_env;
|
||||
}
|
||||
|
||||
/* Free aux stack space */
|
||||
/* Free aux stack space which was allocated in
|
||||
wasm_cluster_spawn_exec_env */
|
||||
bh_assert(exec_env_ts->is_aux_stack_allocated);
|
||||
wasm_cluster_free_aux_stack(exec_env_tls,
|
||||
(uint64)exec_env->aux_stack_bottom);
|
||||
|
||||
|
@ -655,7 +658,9 @@ thread_manager_start_routine(void *arg)
|
|||
#endif
|
||||
|
||||
/* Free aux stack space */
|
||||
wasm_cluster_free_aux_stack(exec_env, (uint64)exec_env->aux_stack_bottom);
|
||||
if (exec_env->is_aux_stack_allocated)
|
||||
wasm_cluster_free_aux_stack(exec_env,
|
||||
(uint64)exec_env->aux_stack_bottom);
|
||||
|
||||
os_mutex_lock(&cluster_list_lock);
|
||||
|
||||
|
@ -723,11 +728,13 @@ wasm_cluster_create_thread(WASMExecEnv *exec_env,
|
|||
aux_stack_size)) {
|
||||
goto fail2;
|
||||
}
|
||||
new_exec_env->is_aux_stack_allocated = true;
|
||||
}
|
||||
else {
|
||||
/* Disable aux stack */
|
||||
new_exec_env->aux_stack_boundary = 0;
|
||||
new_exec_env->aux_stack_bottom = UINTPTR_MAX;
|
||||
new_exec_env->is_aux_stack_allocated = false;
|
||||
}
|
||||
|
||||
/* Inherit suspend_flags of parent thread */
|
||||
|
@ -1049,7 +1056,8 @@ wasm_cluster_exit_thread(WASMExecEnv *exec_env, void *retval)
|
|||
#endif
|
||||
|
||||
/* Free aux stack space */
|
||||
wasm_cluster_free_aux_stack(exec_env, (uint64)exec_env->aux_stack_bottom);
|
||||
if (exec_env->is_aux_stack_allocated)
|
||||
wasm_cluster_free_aux_stack(exec_env, (uint64)exec_env->aux_stack_bottom);
|
||||
|
||||
/* App exit the thread, free the resources before exit native thread */
|
||||
|
||||
|
|
|
@ -675,7 +675,7 @@ main(int argc, char *argv[])
|
|||
#endif
|
||||
#if WASM_ENABLE_GC != 0
|
||||
else if (!strncmp(argv[0], "--gc-heap-size=", 15)) {
|
||||
if (argv[0][21] == '\0')
|
||||
if (argv[0][15] == '\0')
|
||||
return print_help();
|
||||
gc_heap_size = atoi(argv[0] + 15);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user