bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
15.4k stars 1.3k forks source link

Duplicate Definition Error in `define_unknown_imports_as_traps` Method #9615

Open BERADQ opened 2 hours ago

BERADQ commented 2 hours ago

Test Case

// omit ...
linker
    .define_unknown_imports_as_traps(&component_a)
    .unwrap();
let ins_a = linker.instantiate_pre(&component_a).unwrap();
let ins_a = ins_a.instantiate(store_a.as_context_mut())?;
linker
    .define_unknown_imports_as_traps(&component_b)
    .unwrap();
let ins_b = linker.instantiate_pre(&component_b).unwrap();
let ins_b = ins_b.instantiate(store_b.as_context_mut())?;

Steps to Reproduce

Expected Results

The method should handle multiple calls without causing duplicate definitions for any module.

Actual Results

The method results in a duplicate definition error for the wasi module.

map entry `wasi:cli/environment@0.2.0` defined twice

Versions and Environment

Wasmtime version or commit: 26.0.1

Operating system: Windows11 22631.4391

Architecture: rustc 1.84.0-nightly (a93c1718c 2024-10-24)

Extra Info

Possible Solutions:

Exclude Specific Entries: Modify the method to exclude specific entries like wasi from being redefined.

I think it's not a bug at all, but I can't handle it by myself.

BERADQ commented 2 hours ago

allowing_shadowing makes all shadowing legal, which is not very good.