Skip to content

Commit 529fa9d

Browse files
authored
EH: Fix broken stack usage calculation (#3121)
Fixes: #3108
1 parent a32b082 commit 529fa9d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/iwasm/interpreter/wasm_interp_classic.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -4412,19 +4412,20 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
44124412
else {
44134413
WASMFunction *cur_wasm_func = cur_func->u.func;
44144414
WASMType *func_type;
4415+
uint32 max_stack_cell_num = cur_wasm_func->max_stack_cell_num;
44154416

44164417
#if WASM_ENABLE_EXCE_HANDLING != 0
44174418
/* account for exception handlers */
44184419
/* bundle them here */
44194420
uint32 eh_size =
44204421
cur_wasm_func->exception_handler_count * sizeof(uint8 *);
4421-
cur_wasm_func->max_stack_cell_num += eh_size;
4422+
max_stack_cell_num += eh_size;
44224423
#endif
44234424

44244425
func_type = cur_wasm_func->func_type;
44254426

44264427
all_cell_num = cur_func->param_cell_num + cur_func->local_cell_num
4427-
+ cur_wasm_func->max_stack_cell_num
4428+
+ max_stack_cell_num
44284429
+ cur_wasm_func->max_block_num
44294430
* (uint32)sizeof(WASMBranchBlock) / 4;
44304431

@@ -4447,8 +4448,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
44474448

44484449
frame_sp = frame->sp_bottom =
44494450
frame_lp + cur_func->param_cell_num + cur_func->local_cell_num;
4450-
frame->sp_boundary =
4451-
frame->sp_bottom + cur_wasm_func->max_stack_cell_num;
4451+
frame->sp_boundary = frame->sp_bottom + max_stack_cell_num;
44524452

44534453
frame_csp = frame->csp_bottom =
44544454
(WASMBranchBlock *)frame->sp_boundary;

0 commit comments

Comments
 (0)