Stream: git-wasmtime

Topic: wasmtime / issue #7716 Failed to instantiate the example ...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 21 2023 at 04:40):

k82cn added the bug label to Issue #7716.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 21 2023 at 04:40):

k82cn opened issue #7716:

Test Case

package component:matrix;

interface service {
    enum flame-error {
        internal,
    }
    type task-input = list<u8>;
    type task-output = list<u8>;

    record session-context {
        session-id: string,
        common-data: option<list<u8>>,
    }

    record task-context {
        task-id: string,
        session-id: string,
    }

    // handle request function
    on-session-enter: func(ctx: session-context) -> result<_, flame-error>;
    on-session-leave: func(ctx: session-context) -> result<_, flame-error>;
    on-task-invoke: func(ctx: task-context, input: option<task-input>) -> result<option<task-output>, flame-error>;
}

// exports the interface
world flame {
    export service;
}

Steps to Reproduce

References:

Expected Results

Execute the callbacks accordingly, e.g. on_session_enter.

Actual Results

$ ./target/debug/matrix-local
Error: Internal("Failed to instantiate the flame world")

Versions and Environment

Wasmtime version or commit:

wasmtime = "16"
wasmtime-wasi = "16"
anyhow = "1"
$ rustc --version
rustc 1.74.1 (a28077b28 2023-12-04)
$ cargo --version
cargo 1.74.1 (ecb9851af 2023-10-18)

Operating system: Ubuntu 22.04

Architecture: x86

view this post on Zulip Wasmtime GitHub notifications bot (Dec 21 2023 at 05:00):

k82cn commented on issue #7716:

The same issue with the add example:

$ ./target/debug/host-add
Error: Failed to instantiate the example world

Caused by:
    0: import `wasi:cli/environment@0.2.0-rc-2023-11-10` has the wrong type
    1: instance export `get-environment` has the wrong type
    2: expected func found nothing

view this post on Zulip Wasmtime GitHub notifications bot (Dec 21 2023 at 06:02):

k82cn commented on issue #7716:

It works when rollback to wasmtime 15.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 02 2024 at 18:44):

alexcrichton commented on issue #7716:

Thanks for the report! This is probably due to a missing add_to_linker somewhere to register WASI with the linker. Do you have a version of the code to read over which isn't a PR?

view this post on Zulip Wasmtime GitHub notifications bot (Jan 02 2024 at 23:32):

k82cn commented on issue #7716:

Just try it with 16.0, the issue should be there. The version 15 works for me, did not try the latest one.

Reference:

view this post on Zulip Wasmtime GitHub notifications bot (Jan 03 2024 at 17:59):

pchickey commented on issue #7716:

When upgrading from wasmtime-wasi 15 to 16, the version numbers in the wit packages changed. I can't find it in your build, but wherever you are running wasm-tools component new (maybe you are using cargo-component?) you need to change the wasi preview 1 adapter to the version that ships with wasmtime 16 as well, which will match those wit packages.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 05 2024 at 21:42):

zeeshanlakhani commented on issue #7716:

As mentioned in Zulip, I'm suffering from:

running 1 test
thread 'test_crop_base64' panicked at homestar-wasm/tests/execute_wasm.rs:156:10:
called `Result::unwrap()` on an `Err` value: WasmRuntime(import `wasi:cli/environment@0.2.0-rc-2023-12-05` has the wrong type

Caused by:
    0: instance export `get-environment` has the wrong type
    1: expected func found nothing

This happens when compiling my wasm wit-bindgen (version 0.16) code with wasi (it works fine with wasm32-unknown-known). I'm using the reactor version of wasi_snapshot_preview1.wasm from wasmtime 16 when running --adapt. Our runtime, which embeds wasmtime, has:

wasmparser = "0.118"
wasmtime = { version = "16.0", default-features = false, features = [
  "async",
  "component-model",
  "cranelift",
  "parallel-compilation",
  "pooling-allocator",
  "wat",
] }
wasmtime-component-util = "16.0"
wasmtime-wasi = { version = "16.0", default-features = false, features = [
  "tokio",
] }
wat = "1.0"
wit-component = "0.19"

It fails on instantiation:

let instance = linker.instantiate_async(&mut store, &component).await?;
I even removed any WASI bits from the component code, but just focused on targetting wasm32-wasi.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 05 2024 at 22:11):

zeeshanlakhani deleted a comment on issue #7716:

As mentioned in Zulip, I'm suffering from:

running 1 test
thread 'test_crop_base64' panicked at homestar-wasm/tests/execute_wasm.rs:156:10:
called `Result::unwrap()` on an `Err` value: WasmRuntime(import `wasi:cli/environment@0.2.0-rc-2023-12-05` has the wrong type

Caused by:
    0: instance export `get-environment` has the wrong type
    1: expected func found nothing

This happens when compiling my wasm wit-bindgen (version 0.16) code with wasi (it works fine with wasm32-unknown-known). I'm using the reactor version of wasi_snapshot_preview1.wasm from wasmtime 16 when running --adapt. Our runtime, which embeds wasmtime, has:

wasmparser = "0.118"
wasmtime = { version = "16.0", default-features = false, features = [
  "async",
  "component-model",
  "cranelift",
  "parallel-compilation",
  "pooling-allocator",
  "wat",
] }
wasmtime-component-util = "16.0"
wasmtime-wasi = { version = "16.0", default-features = false, features = [
  "tokio",
] }
wat = "1.0"
wit-component = "0.19"

It fails on instantiation:

let instance = linker.instantiate_async(&mut store, &component).await?;
I even removed any WASI bits from the component code, but just focused on targetting wasm32-wasi.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 11 2024 at 22:09):

AccessViolation95 commented on issue #7716:

wherever you are running wasm-tools component new (maybe you are using cargo-component?) you need to change the wasi preview 1 adapter to the version that ships with wasmtime 16 as well

I don't quite understand. Could you be more specific about how to do this? I'm having this issue as well, and for me, switching to Wasmtime 15 did not fix the issue and I don't know how to proceed.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 11 2024 at 22:12):

AccessViolation95 edited a comment on issue #7716:

wherever you are running wasm-tools component new (maybe you are using cargo-component?) you need to change the wasi preview 1 adapter to the version that ships with wasmtime 16 as well

I don't quite understand. Could you be more specific about how to do this? I'm having this issue as well when running a modified version of one of the component model examples, and for me, switching to Wasmtime 15 did not fix the issue and I don't know how to proceed.


Last updated: Dec 23 2024 at 13:07 UTC