mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 13:16:26 +00:00
Fix dead lock in source debugger (#2040)
This commit is contained in:
parent
5c37ddfbca
commit
d75cb3224f
|
@ -1079,12 +1079,14 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst,
|
||||||
/* Record the current frame_ip, so when exception occurs, \
|
/* Record the current frame_ip, so when exception occurs, \
|
||||||
debugger can know the exact opcode who caused the exception */ \
|
debugger can know the exact opcode who caused the exception */ \
|
||||||
frame_ip_orig = frame_ip; \
|
frame_ip_orig = frame_ip; \
|
||||||
|
os_mutex_lock(&exec_env->wait_lock); \
|
||||||
while (exec_env->current_status->signal_flag == WAMR_SIG_SINGSTEP \
|
while (exec_env->current_status->signal_flag == WAMR_SIG_SINGSTEP \
|
||||||
&& exec_env->current_status->step_count++ == 1) { \
|
&& exec_env->current_status->step_count++ == 1) { \
|
||||||
exec_env->current_status->step_count = 0; \
|
exec_env->current_status->step_count = 0; \
|
||||||
SYNC_ALL_TO_FRAME(); \
|
SYNC_ALL_TO_FRAME(); \
|
||||||
wasm_cluster_thread_waiting_run(exec_env); \
|
wasm_cluster_thread_waiting_run(exec_env); \
|
||||||
} \
|
} \
|
||||||
|
os_mutex_unlock(&exec_env->wait_lock); \
|
||||||
goto *handle_table[*frame_ip++]; \
|
goto *handle_table[*frame_ip++]; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
|
@ -1095,12 +1097,14 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst,
|
||||||
#define HANDLE_OP(opcode) case opcode:
|
#define HANDLE_OP(opcode) case opcode:
|
||||||
#if WASM_ENABLE_THREAD_MGR != 0 && WASM_ENABLE_DEBUG_INTERP != 0
|
#if WASM_ENABLE_THREAD_MGR != 0 && WASM_ENABLE_DEBUG_INTERP != 0
|
||||||
#define HANDLE_OP_END() \
|
#define HANDLE_OP_END() \
|
||||||
|
os_mutex_lock(&exec_env->wait_lock); \
|
||||||
if (exec_env->current_status->signal_flag == WAMR_SIG_SINGSTEP \
|
if (exec_env->current_status->signal_flag == WAMR_SIG_SINGSTEP \
|
||||||
&& exec_env->current_status->step_count++ == 2) { \
|
&& exec_env->current_status->step_count++ == 2) { \
|
||||||
exec_env->current_status->step_count = 0; \
|
exec_env->current_status->step_count = 0; \
|
||||||
SYNC_ALL_TO_FRAME(); \
|
SYNC_ALL_TO_FRAME(); \
|
||||||
wasm_cluster_thread_waiting_run(exec_env); \
|
wasm_cluster_thread_waiting_run(exec_env); \
|
||||||
} \
|
} \
|
||||||
|
os_mutex_unlock(&exec_env->wait_lock); \
|
||||||
continue
|
continue
|
||||||
#else
|
#else
|
||||||
#define HANDLE_OP_END() continue
|
#define HANDLE_OP_END() continue
|
||||||
|
|
|
@ -793,18 +793,12 @@ notify_debug_instance_exit(WASMExecEnv *exec_env)
|
||||||
void
|
void
|
||||||
wasm_cluster_thread_waiting_run(WASMExecEnv *exec_env)
|
wasm_cluster_thread_waiting_run(WASMExecEnv *exec_env)
|
||||||
{
|
{
|
||||||
os_mutex_lock(&exec_env->wait_lock);
|
|
||||||
|
|
||||||
/* Wake up debugger thread after we get the lock, otherwise we may miss the
|
|
||||||
* signal from debugger thread, see
|
|
||||||
* https://github.com/bytecodealliance/wasm-micro-runtime/issues/1860 */
|
|
||||||
exec_env->current_status->running_status = STATUS_STOP;
|
exec_env->current_status->running_status = STATUS_STOP;
|
||||||
notify_debug_instance(exec_env);
|
notify_debug_instance(exec_env);
|
||||||
|
|
||||||
while (!wasm_cluster_thread_is_running(exec_env)) {
|
while (!wasm_cluster_thread_is_running(exec_env)) {
|
||||||
os_cond_wait(&exec_env->wait_cond, &exec_env->wait_lock);
|
os_cond_wait(&exec_env->wait_cond, &exec_env->wait_lock);
|
||||||
}
|
}
|
||||||
os_mutex_unlock(&exec_env->wait_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -180,6 +180,9 @@ wasm_cluster_destroy_exenv_status(WASMCurrentEnvStatus *status);
|
||||||
void
|
void
|
||||||
wasm_cluster_send_signal_all(WASMCluster *cluster, uint32 signo);
|
wasm_cluster_send_signal_all(WASMCluster *cluster, uint32 signo);
|
||||||
|
|
||||||
|
/* This function must be called with exec_env->wait_lock locked, otherwise we
|
||||||
|
* may miss the signal from debugger thread, see
|
||||||
|
* https://github.com/bytecodealliance/wasm-micro-runtime/issues/1860 */
|
||||||
void
|
void
|
||||||
wasm_cluster_thread_waiting_run(WASMExecEnv *exec_env);
|
wasm_cluster_thread_waiting_run(WASMExecEnv *exec_env);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user