Sfoglia il codice sorgente

Fix linked global initialization in multimodule (#3905)

While resolving linked globals in multi-module mode, WAMR tries to copy
the linked global's initial value into the destination global in the
current module.  However, a bug in the implementation causes the copy to
be done from the InitializerExpression struct, not from its WASMValue
field.

This did not come up in WAMR's spec test runner because those are built
with WASM_ENABLE_SPEC_TEST, which means these globals are resolved as
builtins, not linked globals, which goes through a different (presumably
not faulty) path.
James Ring 1 anno fa
parent
commit
fdda259d36
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      core/iwasm/interpreter/wasm_runtime.c

+ 1 - 1
core/iwasm/interpreter/wasm_runtime.c

@@ -1209,7 +1209,7 @@ globals_instantiate(WASMModule *module, WASMModuleInstance *module_inst,
             /* The linked global instance has been initialized, we
             /* The linked global instance has been initialized, we
                just need to copy the value. */
                just need to copy the value. */
             bh_memcpy_s(&(global->initial_value), sizeof(WASMValue),
             bh_memcpy_s(&(global->initial_value), sizeof(WASMValue),
-                        &(global_import->import_global_linked->init_expr),
+                        &(global_import->import_global_linked->init_expr.u),
                         sizeof(WASMValue));
                         sizeof(WASMValue));
         }
         }
         else
         else