From 529fa9dd17bd6bb3159711881cac8def76df7277 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sat, 3 Feb 2024 13:21:15 +0900 Subject: [PATCH] EH: Fix broken stack usage calculation (#3121) Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3108 --- core/iwasm/interpreter/wasm_interp_classic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index e4da90b9..1487f071 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -4412,19 +4412,20 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, else { WASMFunction *cur_wasm_func = cur_func->u.func; WASMType *func_type; + uint32 max_stack_cell_num = cur_wasm_func->max_stack_cell_num; #if WASM_ENABLE_EXCE_HANDLING != 0 /* account for exception handlers */ /* bundle them here */ uint32 eh_size = cur_wasm_func->exception_handler_count * sizeof(uint8 *); - cur_wasm_func->max_stack_cell_num += eh_size; + max_stack_cell_num += eh_size; #endif func_type = cur_wasm_func->func_type; all_cell_num = cur_func->param_cell_num + cur_func->local_cell_num - + cur_wasm_func->max_stack_cell_num + + max_stack_cell_num + cur_wasm_func->max_block_num * (uint32)sizeof(WASMBranchBlock) / 4; @@ -4447,8 +4448,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, frame_sp = frame->sp_bottom = frame_lp + cur_func->param_cell_num + cur_func->local_cell_num; - frame->sp_boundary = - frame->sp_bottom + cur_wasm_func->max_stack_cell_num; + frame->sp_boundary = frame->sp_bottom + max_stack_cell_num; frame_csp = frame->csp_bottom = (WASMBranchBlock *)frame->sp_boundary;