{"record":{"id":"c97ace104c703d22","repo":"wasmerio/wasmer","slug":"internal-error-table-base-out-of-sync-with-linker","errorCode":null,"errorMessage":"Internal error: table base out of sync with linker state","messagePattern":"Internal error: table base out of sync with linker state","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/wasix/src/state/linker/instance_group/table.rs","lineNumber":124,"sourceCode":"                was already instantiated in this group\"\n            )\n        };\n\n        let dl_module = linker_state\n            .side_modules\n            .get(&module_handle)\n            .expect(\"Internal error: module not loaded into linker\");\n\n        let table_base = self\n            .allocate_function_table(\n                store,\n                dl_module.dylink_info.mem_info.table_size,\n                dl_module.dylink_info.mem_info.table_alignment,\n            )\n            .map_err(LinkError::TableAllocationError)?;\n\n        if table_base != dl_module.table_base {\n            panic!(\"Internal error: table base out of sync with linker state\");\n        }\n\n        trace!(table_base, \"Allocated table indices for existing module\");\n\n        Ok(())\n    }\n\n    pub(super) fn apply_resolved_function(\n        &self,\n        store: &mut impl AsStoreMut,\n        name: &str,\n        resolved_from: ModuleHandle,\n        function_table_index: u32,\n    ) -> Result<(), LinkError> {\n        trace!(\n            ?name,\n            ?resolved_from,\n            function_table_index,","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/wasix/src/state/linker/instance_group/table.rs#L106-L142","documentation":"After allocating table space for an already-instantiated module, this check compares the newly allocated table base with the module's recorded dylink table_base. If they differ, the linker's allocator and the module's dynamic-linking metadata have drifted, meaning function pointers (table indices) computed at compile time would point to the wrong slots. It aborts rather than silently corrupting indirect calls.","triggerScenarios":"allocate_function_table_for_existing_module (via apply_dl_operation) when the running table allocator's next free index no longer matches dl_module.table_base, e.g. because other allocations were made in between or the module was compiled with different dylink metadata.","commonSituations":"Mixed-version shared objects: modules compiled by a different compiler/linker version with inconsistent table_base/table_size; interleaving manual table allocations with dynamic loads; loading modules into a group whose table was grown out-of-band.","solutions":["Recompile all shared modules with the same compiler/toolchain version so their table_base metadata is consistent","Load modules in a deterministic order and avoid manual function-table allocations between dynamic loads","Rebuild the instance group from scratch instead of reusing a table that has drifted","If reproducible with same-version modules, report as a linker bug with the module set and load order"],"exampleFix":"// before: mixing .so files built with different toolchains\nload(\"liba-v1.so\"); // table_base=1\nload(\"libb-v2.so\"); // table_base mismatch -> panic\n// after: rebuild all shared libs with the same version\nload(\"liba-v2.so\");\nload(\"libb-v2.so\");","handlingStrategy":"validation","validationCode":"fn bases_match(allocated_base: u64, module: &DlModule) -> bool {\n    allocated_base == module.dylink_info.table_base\n}\n// before allocating: verify toolchain versions match for all shared modules","typeGuard":"fn same_toolchain(mods: &[&DlModule]) -> bool {\n    mods.iter().all(|m| m.toolchain_version == mods[0].toolchain_version)\n}","tryCatchPattern":null,"preventionTips":["Compile all shared modules with the same compiler/linker version","Load modules in a deterministic order without interleaved manual allocations","Validate dylink metadata (table_base/size) at load time","Recreate the group from scratch when a mismatch is detected"],"tags":["linker","table-base","dylink","internal-invariant","panic"],"backgroundTag":"linker-table-base-mismatch","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}