Skip to content

Commit 21819fc

Browse files
Fix dynamic offset in BR for block with return type (#3192)
The issue was reported in #3170.
1 parent 5635244 commit 21819fc

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

core/iwasm/interpreter/wasm_loader.c

+1
Original file line numberDiff line numberDiff line change
@@ -9028,6 +9028,7 @@ wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp,
90289028
/* Part e */
90299029
dynamic_offset =
90309030
frame_csp->dynamic_offset + wasm_get_cell_num(types, arity);
9031+
ctx->dynamic_offset = dynamic_offset;
90319032
for (i = (int32)arity - 1; i >= 0; i--) {
90329033
cell = (uint8)wasm_value_type_cell_num(types[i]);
90339034
dynamic_offset -= cell;

core/iwasm/interpreter/wasm_mini_loader.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -4750,6 +4750,7 @@ wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp,
47504750
/* Part e */
47514751
dynamic_offset =
47524752
frame_csp->dynamic_offset + wasm_get_cell_num(types, arity);
4753+
ctx->dynamic_offset = dynamic_offset;
47534754
for (i = (int32)arity - 1; i >= 0; i--) {
47544755
cell = (uint8)wasm_value_type_cell_num(types[i]);
47554756
dynamic_offset -= cell;
@@ -5552,9 +5553,6 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
55525553
frame_ref_buf, total_size);
55535554

55545555
#if WASM_ENABLE_FAST_INTERP != 0
5555-
/* The stack operand num should not be smaller than before
5556-
after pop and push operations */
5557-
bh_assert(loader_ctx->reftype_map_num >= reftype_map_num_old);
55585556
loader_ctx->frame_offset =
55595557
loader_ctx->frame_offset_bottom + stack_cell_num_old;
55605558
total_size = (uint32)sizeof(int16)

0 commit comments

Comments
 (0)