Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -11227,6 +11227,13 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
bool disable_emit, preserve_local = false, if_condition_available = true;
float32 f32_const;
float64 f64_const;
/*
* It means that the fast interpreter detected an exception while preparing,
* typically near the block opcode, but it did not immediately trigger
* the exception. The loader should be capable of identifying it near
* the end opcode and then raising the exception.
*/
bool pending_exception = false;

LOG_OP("\nProcessing func | [%d] params | [%d] locals | [%d] return\n",
func->param_cell_num, func->local_cell_num, func->ret_cell_num);
Expand Down Expand Up @@ -11577,6 +11584,16 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
cell_num = wasm_value_type_cell_num(
wasm_type->types[wasm_type->param_count - i - 1]);
loader_ctx->frame_offset -= cell_num;

if (loader_ctx->frame_offset
< loader_ctx->frame_offset_bottom) {
LOG_DEBUG(
"frame_offset underflow, roll back and "
"let following stack checker report it\n");
loader_ctx->frame_offset += cell_num;
pending_exception = true;
break;
}
#endif
}
}
Expand Down Expand Up @@ -12099,6 +12116,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
}
}

#if WASM_ENABLE_FAST_INTERP != 0
if (pending_exception) {
set_error_buf(
error_buf, error_buf_size,
"There is a pending exception needs to be handled");
goto fail;
}
#endif

break;
}

Expand Down
Loading