Stream: git-wasmtime

Topic: wasmtime / issue #9487 `T cannot be sent between threads...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 19 2024 at 21:00):

HKalbasi added the bug label to Issue #9487.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 19 2024 at 21:00):

HKalbasi opened issue #9487:

I have this macro:

bindgen!({
    world: "gav",
    with: {
        "wasi": wasmtime_wasi::bindings,
        "wasi:http": wasmtime_wasi_http::bindings::http,
    },
});

And its generated code fails to compile with this error:

error[E0277]: `T` cannot be sent between threads safely
   --> src/main.rs:5:1
    |
5   | / bindgen!({
6   | |     world: "gav",
7   | |
8   | |     with: {
...   |
11  | |     },
12  | | });
    | |__^ `T` cannot be sent between threads safely
    |
note: required by a bound in `wasmtime_wasi::bindings::sync::io::poll::add_to_linker`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-wasi-25.0.2/src/bindings.rs:148:9
    |
148 | /         wasmtime::component::bindgen!({
149 | |             path: "wit",
150 | |             world: "wasi:cli/command",
151 | |             tracing: true,
...   |
181 | |             require_store_data_send: true,
182 | |         });
    | |__________^ required by this bound in `add_to_linker`
    = note: this error originates in the macro `bindgen` which comes from the expansion of the macro `wasmtime::component::bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider further restricting type parameter `T`
    |
12  | }), T: std::marker::Send;
    |   ++++++++++++++++++++++

It seems some Send bounds are missing from the add_to_linker functions. Using wasmtime_wasi::bindings::sync instead of wasmtime_wasi::bindings didn't help.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 19 2024 at 22:42):

bjorn3 commented on issue #9487:

Does it work if you add async: true to the bindgen invocation?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 20 2024 at 17:33):

HKalbasi commented on issue #9487:

Yes, but I don't want async I think.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 20 2024 at 18:00):

bjorn3 commented on issue #9487:

In that case I think you have to do:

bindgen!({
    world: "gav",
    with: {
        "wasi": wasmtime_wasi::bindings::sync,
        "wasi:http": wasmtime_wasi_http::bindings::sync::http,
    },
});

view this post on Zulip Wasmtime GitHub notifications bot (Oct 20 2024 at 19:06):

HKalbasi commented on issue #9487:

This one doesn't work. It fails with the same error of original post.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 21 2024 at 09:13):

alexcrichton commented on issue #9487:

Does this option, notably require_store_data_send: true, work for you? (it's sort of buried in the documentation)

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2024 at 07:51):

HKalbasi closed issue #9487:

I have this macro:

bindgen!({
    world: "gav",
    with: {
        "wasi": wasmtime_wasi::bindings,
        "wasi:http": wasmtime_wasi_http::bindings::http,
    },
});

And its generated code fails to compile with this error:

error[E0277]: `T` cannot be sent between threads safely
   --> src/main.rs:5:1
    |
5   | / bindgen!({
6   | |     world: "gav",
7   | |
8   | |     with: {
...   |
11  | |     },
12  | | });
    | |__^ `T` cannot be sent between threads safely
    |
note: required by a bound in `wasmtime_wasi::bindings::sync::io::poll::add_to_linker`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-wasi-25.0.2/src/bindings.rs:148:9
    |
148 | /         wasmtime::component::bindgen!({
149 | |             path: "wit",
150 | |             world: "wasi:cli/command",
151 | |             tracing: true,
...   |
181 | |             require_store_data_send: true,
182 | |         });
    | |__________^ required by this bound in `add_to_linker`
    = note: this error originates in the macro `bindgen` which comes from the expansion of the macro `wasmtime::component::bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider further restricting type parameter `T`
    |
12  | }), T: std::marker::Send;
    |   ++++++++++++++++++++++

It seems some Send bounds are missing from the add_to_linker functions. Using wasmtime_wasi::bindings::sync instead of wasmtime_wasi::bindings didn't help.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2024 at 07:51):

HKalbasi commented on issue #9487:

This works, thanks!


Last updated: Nov 22 2024 at 16:03 UTC