Stream: git-wasmtime

Topic: wasmtime / issue #3388 Poor linking error message with mo...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2021 at 18:27):

alexcrichton opened issue #3388:

For this program:

use wasmtime::*;

fn main() {
    let mut config = Config::new();
    config.wasm_module_linking(true);
    let engine = Engine::new(&config).unwrap();
    let module = Module::new(
        &engine,
        r#"
        (module
            (import "foo" "bar" (func))
        )
    "#,
    )
    .unwrap();

    let mut linker = Linker::new(&engine);
    linker.func_wrap("foo", "baz", || {}).unwrap();
    let mut store = Store::new(&engine, ());
    println!("{:?}", linker.instantiate(&mut store, &module).unwrap_err());
}

it generates this error message:

unknown import: `foo` has not been defined

whereas if module linking is disabled it generates:

unknown import: `foo::bar` has not been defined

The latter error message here is much better than the former. The reason for this is how Wasmtime reinterprets two-level imports as single-level-imports-of-instances, but the error message generation doesn't do a great job of taking this into account.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2021 at 18:28):

alexcrichton labeled issue #3388:

For this program:

use wasmtime::*;

fn main() {
    let mut config = Config::new();
    config.wasm_module_linking(true);
    let engine = Engine::new(&config).unwrap();
    let module = Module::new(
        &engine,
        r#"
        (module
            (import "foo" "bar" (func))
        )
    "#,
    )
    .unwrap();

    let mut linker = Linker::new(&engine);
    linker.func_wrap("foo", "baz", || {}).unwrap();
    let mut store = Store::new(&engine, ());
    println!("{:?}", linker.instantiate(&mut store, &module).unwrap_err());
}

it generates this error message:

unknown import: `foo` has not been defined

whereas if module linking is disabled it generates:

unknown import: `foo::bar` has not been defined

The latter error message here is much better than the former. The reason for this is how Wasmtime reinterprets two-level imports as single-level-imports-of-instances, but the error message generation doesn't do a great job of taking this into account.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2021 at 18:28):

github-actions[bot] commented on issue #3388:

Subscribe to Label Action

cc @peterhuene

<details>
This issue or pull request has been labeled: "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2021 at 17:16):

alexcrichton commented on issue #3388:

Fixed in https://github.com/bytecodealliance/wasmtime/pull/3456

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2021 at 17:16):

alexcrichton closed issue #3388:

For this program:

use wasmtime::*;

fn main() {
    let mut config = Config::new();
    config.wasm_module_linking(true);
    let engine = Engine::new(&config).unwrap();
    let module = Module::new(
        &engine,
        r#"
        (module
            (import "foo" "bar" (func))
        )
    "#,
    )
    .unwrap();

    let mut linker = Linker::new(&engine);
    linker.func_wrap("foo", "baz", || {}).unwrap();
    let mut store = Store::new(&engine, ());
    println!("{:?}", linker.instantiate(&mut store, &module).unwrap_err());
}

it generates this error message:

unknown import: `foo` has not been defined

whereas if module linking is disabled it generates:

unknown import: `foo::bar` has not been defined

The latter error message here is much better than the former. The reason for this is how Wasmtime reinterprets two-level imports as single-level-imports-of-instances, but the error message generation doesn't do a great job of taking this into account.


Last updated: Oct 23 2024 at 20:03 UTC