Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wai-bindgen-rust does not compile: error[E0277]: RefCell<State> cannot be shared between threads safely #43

Open
wellcaffeinated opened this issue May 31, 2023 · 3 comments

Comments

@wellcaffeinated
Copy link

Hi there. I'm getting the following error when trying to compile my wapm package with the command:

RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals' \
    rustup run nightly-2023-05-31 \
    cargo build --target wasm32-wasi --release
   Compiling wai-bindgen-rust v0.2.3
error[E0277]: `RefCell<State>` cannot be shared between threads safely
  --> /Users/wellcaffeinated/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wai-bindgen-rust-0.2.3/src/futures.rs:72:34
   |
72 |         let waker = self.clone().into();
   |                                  ^^^^ `RefCell<State>` cannot be shared between threads safely
   |
   = help: within `PollingWaker`, the trait `Sync` is not implemented for `RefCell<State>`
   = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead
note: required because it appears within the type `PollingWaker`
  --> /Users/wellcaffeinated/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wai-bindgen-rust-0.2.3/src/futures.rs:22:8
   |
22 | struct PollingWaker {
   |        ^^^^^^^^^^^^
   = note: required for `std::task::Waker` to implement `From<Arc<PollingWaker>>`
   = note: required for `Arc<PollingWaker>` to implement `Into<std::task::Waker>`

error[E0277]: `(dyn Future<Output = ()> + 'static)` cannot be sent between threads safely
  --> /Users/wellcaffeinated/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wai-bindgen-rust-0.2.3/src/futures.rs:72:34
   |
72 |         let waker = self.clone().into();
   |                                  ^^^^ `(dyn Future<Output = ()> + 'static)` cannot be sent between threads safely
   |
   = help: the trait `Send` is not implemented for `(dyn Future<Output = ()> + 'static)`
   = note: required for `Unique<(dyn Future<Output = ()> + 'static)>` to implement `Send`
note: required because it appears within the type `Box<dyn Future<Output = ()>>`
  --> /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/alloc/src/boxed.rs:195:12
note: required because it appears within the type `Pin<Box<dyn Future<Output = ()>>>`
  --> /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/pin.rs:410:12
note: required because it appears within the type `State`
  --> /Users/wellcaffeinated/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wai-bindgen-rust-0.2.3/src/futures.rs:26:6
   |
26 | enum State {
   |      ^^^^^
   = note: required for `RefCell<State>` to implement `Send`
note: required because it appears within the type `PollingWaker`
  --> /Users/wellcaffeinated/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wai-bindgen-rust-0.2.3/src/futures.rs:22:8
   |
22 | struct PollingWaker {
   |        ^^^^^^^^^^^^
   = note: required for `std::task::Waker` to implement `From<Arc<PollingWaker>>`
   = note: required for `Arc<PollingWaker>` to implement `Into<std::task::Waker>`

For more information about this error, try `rustc --explain E0277`.
@gfyrag
Copy link

gfyrag commented Mar 16, 2024

Hi @wellcaffeinated !
Did you solve this problem?

@wellcaffeinated
Copy link
Author

No unfortunately 😕

@gfyrag
Copy link

gfyrag commented Mar 17, 2024

For information, this occur also using a plain cargo wasix build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants