Skip to content

Commit 165c571

Browse files
committed
fix: update assert condition and move termination check
1 parent 7d5a808 commit 165c571

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

core/iwasm/common/wasm_runtime_common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ runtime_signal_handler(void *sig_addr)
194194
else if (exec_env_tls->exce_check_guard_page <= (uint8 *)sig_addr
195195
&& (uint8 *)sig_addr
196196
< exec_env_tls->exce_check_guard_page + page_size) {
197+
bh_assert(wasm_get_exception(module_inst)
198+
#if WASM_ENABLE_THREAD_MGR != 0
199+
|| wasm_cluster_is_thread_terminated(exec_env_tls)
200+
#endif
201+
);
197202
os_longjmp(jmpbuf_node->jmpbuf, 1);
198203
}
199204
}

core/iwasm/compilation/aot_emit_function.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -857,14 +857,6 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
857857
goto fail;
858858
}
859859

860-
#if WASM_ENABLE_THREAD_MGR != 0
861-
/* Insert suspend check point */
862-
if (comp_ctx->enable_thread_mgr) {
863-
if (!check_suspend_flags(comp_ctx, func_ctx))
864-
return false;
865-
}
866-
#endif
867-
868860
/* Check whether there was exception thrown when executing
869861
the function */
870862
if (!check_exception_thrown(comp_ctx, func_ctx)) {
@@ -1007,6 +999,14 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
1007999
}
10081000
#endif
10091001

1002+
#if WASM_ENABLE_THREAD_MGR != 0
1003+
/* Insert suspend check point */
1004+
if (comp_ctx->enable_thread_mgr) {
1005+
if (!check_suspend_flags(comp_ctx, func_ctx))
1006+
return false;
1007+
}
1008+
#endif
1009+
10101010
ret = true;
10111011
fail:
10121012
if (param_types)
@@ -1653,6 +1653,14 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
16531653
}
16541654
#endif
16551655

1656+
#if WASM_ENABLE_THREAD_MGR != 0
1657+
/* Insert suspend check point */
1658+
if (comp_ctx->enable_thread_mgr) {
1659+
if (!check_suspend_flags(comp_ctx, func_ctx))
1660+
return false;
1661+
}
1662+
#endif
1663+
16561664
ret = true;
16571665

16581666
fail:

core/iwasm/libraries/thread-mgr/thread_manager.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,8 @@ wasm_cluster_spread_exception(WASMExecEnv *exec_env, bool clear)
11611161
WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env);
11621162
bh_assert(cluster);
11631163

1164+
set_thread_cancel_flags(exec_env);
1165+
11641166
os_mutex_lock(&cluster->lock);
11651167
cluster->has_exception = !clear;
11661168
traverse_list(&cluster->exec_env_list,

0 commit comments

Comments
 (0)