Fix potential recursive lock in pthread_create_wrapper (#2980)

Potential recursive lock occurs in:
```
pthread_create_wrapper   (acquire exec_env->wait_lock)
  => wasm_cluster_create_thread
    => allocate_aux_stack
      => wasm_runtime_module_malloc_internal
        => wasm_call_function
          => wasm_exec_env_set_thread_info (acquire exec_env->wait_lock again)
```
Allocate aux stack before calling wasm_cluster_create_thread to resolve it.

Reported in https://github.com/bytecodealliance/wasm-micro-runtime/pull/2977.
This commit is contained in:
Wenyong Huang
2024-01-08 09:43:31 +08:00
committed by GitHub
parent 4a1ad9a160
commit c39214e8a5
4 changed files with 64 additions and 22 deletions

View File

@ -119,7 +119,7 @@ thread_spawn_wrapper(wasm_exec_env_t exec_env, uint32 start_arg)
thread_start_arg->arg = start_arg;
thread_start_arg->start_func = start_func;
ret = wasm_cluster_create_thread(exec_env, new_module_inst, false,
ret = wasm_cluster_create_thread(exec_env, new_module_inst, false, 0, 0,
thread_start, thread_start_arg);
if (ret != 0) {
LOG_ERROR("Failed to spawn a new thread");