@@ -610,16 +610,16 @@ notify_debug_instance_exit(WASMExecEnv *exec_env)
610610}
611611
612612void
613- wasm_cluster_thread_stopped (WASMExecEnv * exec_env )
613+ wasm_cluster_thread_waiting_run (WASMExecEnv * exec_env )
614614{
615+ os_mutex_lock (& exec_env -> wait_lock );
616+
617+ /* Wake up debugger thread after we get the lock, otherwise we may miss the
618+ * signal from debugger thread, see
619+ * https://github.com/bytecodealliance/wasm-micro-runtime/issues/1860 */
615620 exec_env -> current_status -> running_status = STATUS_STOP ;
616621 notify_debug_instance (exec_env );
617- }
618622
619- void
620- wasm_cluster_thread_waiting_run (WASMExecEnv * exec_env )
621- {
622- os_mutex_lock (& exec_env -> wait_lock );
623623 while (!wasm_cluster_thread_is_running (exec_env )) {
624624 os_cond_wait (& exec_env -> wait_cond , & exec_env -> wait_lock );
625625 }
@@ -646,16 +646,20 @@ wasm_cluster_thread_exited(WASMExecEnv *exec_env)
646646void
647647wasm_cluster_thread_continue (WASMExecEnv * exec_env )
648648{
649+ os_mutex_lock (& exec_env -> wait_lock );
649650 wasm_cluster_clear_thread_signal (exec_env );
650651 exec_env -> current_status -> running_status = STATUS_RUNNING ;
651652 os_cond_signal (& exec_env -> wait_cond );
653+ os_mutex_unlock (& exec_env -> wait_lock );
652654}
653655
654656void
655657wasm_cluster_thread_step (WASMExecEnv * exec_env )
656658{
659+ os_mutex_lock (& exec_env -> wait_lock );
657660 exec_env -> current_status -> running_status = STATUS_STEP ;
658661 os_cond_signal (& exec_env -> wait_cond );
662+ os_mutex_unlock (& exec_env -> wait_lock );
659663}
660664
661665void
0 commit comments