Skip to content

Commit

Permalink
Correct the table index calculation in aot_instantiation (#3903)
Browse files Browse the repository at this point in the history
`module_inst->table_count = module->import_table_count + module->table_count`,
using it as an index will go through `module->import_tables` and  `module->tables`,
but aot init data is only available for non-import tables.
  • Loading branch information
lum1n0us authored Nov 18, 2024
1 parent 0e4dffc commit 0119b17
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/iwasm/aot/aot_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
bool ret = false;
#endif

/* Check heap size */
/* Align and validate heap size */
heap_size = align_uint(heap_size, 8);
if (heap_size > APP_HEAP_SIZE_MAX)
heap_size = APP_HEAP_SIZE_MAX;
Expand Down Expand Up @@ -2001,7 +2001,11 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
AOTTableInstance *table_inst;
table_elem_type_t *table_data;

table = &module->tables[i];
/* bypass imported table since AOTImportTable doesn't have init_expr */
if (i < module->import_table_count)
continue;

table = &module->tables[i - module->import_table_count];
bh_assert(table);

if (table->init_expr.init_expr_type == INIT_EXPR_NONE) {
Expand Down

0 comments on commit 0119b17

Please sign in to comment.