-
Notifications
You must be signed in to change notification settings - Fork 724
Description
When a block
/loop
has multiple different reference parameters, the reftype
is not updated to each parameter when compared to the popped parameter value from the stack, leading to unexpected type mismatch exception.
Test case
(i32.const 10)
(struct.new $struct_a ...)
(i32.const 20)
(struct.new $struct_b ...)
(block (param i32 (ref $struct_a) i32 (ref $struct_b)) (result (ref $struct_c)) ... )
Your environment
- Host OS: Linux
- WAMR 2.4.2, x86-64, classic-interp
Steps to reproduce
Load a module with such block
/ loop
instructions.
Expected behavior
Load successfully.
Actual behavior
Error loading wasm module: WASM module load failed: type mismatch: expect (ref ht) but got other
Extra Info
Only in this block:
wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c
Lines 11955 to 11956 in 6450d87
/* Pass parameters to block */ | |
if (BLOCK_HAS_PARAM(block_type)) { |
was the wasm_ref_type
a.k.a. loader_ctx->ref_type_tmp
set properly:
wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c
Lines 11991 to 12000 in 6450d87
#if WASM_ENABLE_GC != 0 | |
if (wasm_is_type_multi_byte_type(func_type->types[i])) { | |
bh_assert(func_type->ref_type_maps[j].index == i); | |
ref_type = func_type->ref_type_maps[j].ref_type; | |
bh_memcpy_s(&wasm_ref_type, sizeof(WASMRefType), | |
ref_type, | |
wasm_reftype_struct_size(ref_type)); | |
j++; | |
} | |
#endif |
But not in this block (earlier):
wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c
Lines 11909 to 11910 in 6450d87
/* Pop block parameters from stack */ | |
if (BLOCK_HAS_PARAM(block_type)) { |