host_consume_stack_and_call_indirect: add an ad-hoc overflow detection

This commit is contained in:
YAMAMOTO Takashi 2024-04-22 13:53:11 +09:00
parent b511ad9c50
commit 262075db02

View File

@ -38,6 +38,11 @@ host_consume_stack_and_call_indirect(wasm_exec_env_t exec_env, uint32_t funcidx,
void *boundary = os_thread_get_stack_boundary();
void *fp = __builtin_frame_address(0);
ptrdiff_t diff = fp - boundary;
if ((unsigned char *)fp < (unsigned char *)boundary + 1024 * 5) {
wasm_runtime_set_exception(wasm_runtime_get_module_inst(exec_env),
"native stack overflow 2");
return 0;
}
if (diff > stack) {
prev_diff = diff;
nest++;