Skip to content

Commit 0119b17

Browse files
authored
Correct the table index calculation in aot_instantiation (#3903)
`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.
1 parent 0e4dffc commit 0119b17

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/iwasm/aot/aot_runtime.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,7 +1785,7 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
17851785
bool ret = false;
17861786
#endif
17871787

1788-
/* Check heap size */
1788+
/* Align and validate heap size */
17891789
heap_size = align_uint(heap_size, 8);
17901790
if (heap_size > APP_HEAP_SIZE_MAX)
17911791
heap_size = APP_HEAP_SIZE_MAX;
@@ -2001,7 +2001,11 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
20012001
AOTTableInstance *table_inst;
20022002
table_elem_type_t *table_data;
20032003

2004-
table = &module->tables[i];
2004+
/* bypass imported table since AOTImportTable doesn't have init_expr */
2005+
if (i < module->import_table_count)
2006+
continue;
2007+
2008+
table = &module->tables[i - module->import_table_count];
20052009
bh_assert(table);
20062010

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

0 commit comments

Comments
 (0)