From d7b6bc5aca989f8a558249518d51274d0b0c92ba Mon Sep 17 00:00:00 2001 From: Liu Jia Date: Sun, 12 Oct 2025 20:18:25 +0800 Subject: [PATCH] Add a watchdog to prevent the similar crash in AOT mode (#4625) --- core/iwasm/aot/aot_runtime.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 3bf33e127..2c7df68e6 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -114,6 +114,13 @@ set_error_buf_v(char *error_buf, uint32 error_buf_size, const char *format, ...) } } +static void +aot_unlinked_import_func_trap(WASMExecEnv *exec_env) +{ + AOTModuleInstance *module_inst = (AOTModuleInstance *)exec_env->module_inst; + aot_set_exception_with_id(module_inst, EXCE_CALL_UNLINKED_IMPORT_FUNC); +} + static void * runtime_malloc(uint64 size, char *error_buf, uint32 error_buf_size) { @@ -1397,6 +1404,7 @@ init_func_ptrs(AOTModuleInstance *module_inst, AOTModule *module, * Debugging: Check if the import is resolved at link time */ LOG_WARNING("warning: failed to link import function (%s, %s)", module_name, field_name); + *func_ptrs = (void *)aot_unlinked_import_func_trap; } }