Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/iwasm/libraries/thread-mgr/thread_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@ wasm_cluster_join_thread(WASMExecEnv *exec_env, void **ret_val)
int32
wasm_cluster_detach_thread(WASMExecEnv *exec_env)
{
if (exec_env->thread_is_detached)
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should move the code into the lock/unlock code piece, e.g. :

    os_mutex_lock(&cluster_list_lock);
    if (exec_env->thread_is_detached) {
        os_mutex_unlock(&cluster_list_lock);
        return 0;
    }
    if (!clusters_have_exec_env(exec_env)) {
    ...
    os_mutex_unlock(&cluster_list_lock);

Or if another thread changes the state when current thread runs between L701 and L705, current thread will change again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I have moved it into lock protection.


int32 ret = 0;

os_mutex_lock(&cluster_list_lock);
Expand Down