-
Notifications
You must be signed in to change notification settings - Fork 737
Allow HW OOB exception propagate from callee to caller issue when multi-module is enabled #4714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Allow HW OOB exception propagate from callee to caller issue when multi-module is enabled #4714
Conversation
|
Will add a test case too |
2533f0c to
c53d251
Compare
c53d251 to
b846382
Compare
lum1n0us
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is another smaller solution by using wasm_exec_env_restore_module_inst() in call_wasm_with_hw_bound_check() when an exception occurs.
diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c
index 7ac6a66f..81d1223a 100644
--- a/core/iwasm/interpreter/wasm_runtime.c
+++ b/core/iwasm/interpreter/wasm_runtime.c
@@ -3665,6 +3665,11 @@ call_wasm_with_hw_bound_check(WASMModuleInstance *module_inst,
/* Restore operand frames */
wasm_exec_env_set_cur_frame(exec_env, prev_frame);
exec_env->wasm_stack.top = prev_top;
+ /* Restore instance*/
+ if ((uintptr_t)module_inst != (uintptr_t)exec_env->module_inst) {
+ wasm_exec_env_restore_module_inst(exec_env,
+ (WASMModuleInstanceCommon *)module_inst);
+ }
}
jmpbuf_node_pop = wasm_exec_env_pop_jmpbuf(exec_env);| (WASMModuleInstanceCommon *)jmpbuf_node->module_inst, | ||
| (WASMModuleInstanceCommon *)module_inst); | ||
| } | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure why we need WASM_ENABLE_MULTI_MODULE handling in this low level logic.
exception propagation should be done regardless of hw bound check, shouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This specific case #4703 occurs only when an exception happens in the child module instance, and the main module instance fails to copy that exception, causing the problem.
We both agree that there is another simple solution for this issue.
However, in the short term, I can't determine under which circumstances it is necessary to switch module instances before calling a WASM function. Please enlighten me.
No description provided.