Ver Fonte

Add a watchdog to prevent the similar crash in AOT mode (#4625)

Liu Jia há 4 meses atrás
pai
commit
d7b6bc5aca
1 ficheiros alterados com 8 adições e 0 exclusões
  1. 8 0
      core/iwasm/aot/aot_runtime.c

+ 8 - 0
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;
         }
     }