@@ -11227,6 +11227,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1122711227 bool disable_emit, preserve_local = false, if_condition_available = true;
1122811228 float32 f32_const;
1122911229 float64 f64_const;
11230+ bool pending_exception = false;
1123011231
1123111232 LOG_OP("\nProcessing func | [%d] params | [%d] locals | [%d] return\n",
1123211233 func->param_cell_num, func->local_cell_num, func->ret_cell_num);
@@ -11577,6 +11578,16 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1157711578 cell_num = wasm_value_type_cell_num(
1157811579 wasm_type->types[wasm_type->param_count - i - 1]);
1157911580 loader_ctx->frame_offset -= cell_num;
11581+
11582+ if (loader_ctx->frame_offset
11583+ < loader_ctx->frame_offset_bottom) {
11584+ LOG_DEBUG(
11585+ "frame_offset underflow, roll back and "
11586+ "let following stack checker report it\n");
11587+ loader_ctx->frame_offset += cell_num;
11588+ pending_exception = true;
11589+ break;
11590+ }
1158011591#endif
1158111592 }
1158211593 }
@@ -12099,6 +12110,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1209912110 }
1210012111 }
1210112112
12113+ #if WASM_ENABLE_FAST_INTERP != 0
12114+ if (pending_exception) {
12115+ set_error_buf(
12116+ error_buf, error_buf_size,
12117+ "There is a pending exception needs to be handled");
12118+ goto fail;
12119+ }
12120+ #endif
12121+
1210212122 break;
1210312123 }
1210412124
0 commit comments