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

*mut u8` cannot be sent between threads safely async_std #910

Open
makorne opened this issue Nov 7, 2022 · 0 comments · May be fixed by #2074
Open

*mut u8` cannot be sent between threads safely async_std #910

makorne opened this issue Nov 7, 2022 · 0 comments · May be fixed by #2074

Comments

@makorne
Copy link

makorne commented Nov 7, 2022

cargo build --lib --target wasm32-unknown-unknown

Compiling opentelemetry_sdk v0.18.0 (https://github.com/makorne/opentelemetry-rust.git#9021b4f9)
error[E0277]: `*mut u8` cannot be sent between threads safely
   --> /home/den/.cargo/git/checkouts/opentelemetry-rust-e60293f9fcf2de72/9021b4f/opentelemetry-sdk/src/runtime.rs:116:21
    |
116 |     type Interval = async_std::stream::Interval;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut u8` cannot be sent between threads safely
    |
    = help: within `Interval`, the trait `std::marker::Send` is not implemented for `*mut u8`
    = note: required because it appears within the type `PhantomData<*mut u8>`
    = note: required because it appears within the type `wasm_bindgen::JsValue`
    = note: required because it appears within the type `ManuallyDrop<wasm_bindgen::JsValue>`
    = note: required because it appears within the type `wasm_bindgen::closure::Closure<(dyn FnMut() + 'static)>`
    = note: required because it appears within the type `Option<wasm_bindgen::closure::Closure<(dyn FnMut() + 'static)>>`
    = note: required because it appears within the type `gloo_timers::callback::Timeout`
    = note: required because it appears within the type `gloo_timers::future::TimeoutFuture`
    = note: required because it appears within the type `async_std::utils::timer::Timer`
    = note: required because it appears within the type `Interval`
note: required by a bound in `Runtime::Interval`
   --> /home/den/.cargo/git/checkouts/opentelemetry-rust-e60293f9fcf2de72/9021b4f/opentelemetry-sdk/src/runtime.rs:20:29
    |
20  |     type Interval: Stream + Send;
    |                             ^^^^ required by this bound in `Runtime::Interval`

error[E0277]: `(dyn FnMut() + 'static)` cannot be sent between threads safely
   --> /home/den/.cargo/git/checkouts/opentelemetry-rust-e60293f9fcf2de72/9021b4f/opentelemetry-sdk/src/runtime.rs:116:21
    |
116 |     type Interval = async_std::stream::Interval;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn FnMut() + 'static)` cannot be sent between threads safely
    |
    = help: the trait `std::marker::Send` is not implemented for `(dyn FnMut() + 'static)`
    = note: required because of the requirements on the impl of `std::marker::Send` for `Unique<(dyn FnMut() + 'static)>`
    = note: required because it appears within the type `Box<(dyn FnMut() + 'static)>`
    = note: required because it appears within the type `ManuallyDrop<Box<(dyn FnMut() + 'static)>>`
    = note: required because it appears within the type `wasm_bindgen::closure::Closure<(dyn FnMut() + 'static)>`
    = note: required because it appears within the type `Option<wasm_bindgen::closure::Closure<(dyn FnMut() + 'static)>>`
    = note: required because it appears within the type `gloo_timers::callback::Timeout`
    = note: required because it appears within the type `gloo_timers::future::TimeoutFuture`
    = note: required because it appears within the type `async_std::utils::timer::Timer`
    = note: required because it appears within the type `Interval`
note: required by a bound in `Runtime::Interval`
   --> /home/den/.cargo/git/checkouts/opentelemetry-rust-e60293f9fcf2de72/9021b4f/opentelemetry-sdk/src/runtime.rs:20:29
    |
20  |     type Interval: Stream + Send;
    |                             ^^^^ required by this bound in `Runtime::Interval`

error[E0277]: expected a `FnOnce<()>` closure, found `Pin<Box<dyn futures_util::Future<Output = ()> + std::marker::Send>>`
   --> /home/den/.cargo/git/checkouts/opentelemetry-rust-e60293f9fcf2de72/9021b4f/opentelemetry-sdk/src/runtime.rs:124:23
    |
124 |         let _ = spawn(future);
    |                 ----- ^^^^^^ expected an `FnOnce<()>` closure, found `Pin<Box<dyn futures_util::Future<Output = ()> + std::marker::Send>>`
    |                 |
    |                 required by a bound introduced by this call
    |
    = help: the trait `FnOnce<()>` is not implemented for `Pin<Box<dyn futures_util::Future<Output = ()> + std::marker::Send>>`
    = note: wrap the `Pin<Box<dyn futures_util::Future<Output = ()> + std::marker::Send>>` in a closure with no arguments: `|| { /* code */ }`
note: required by a bound in `std::thread::spawn`
   --> /home/den/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:652:8
    |
652 |     F: FnOnce() -> T,
    |        ^^^^^^^^^^^^^ required by this bound in `std::thread::spawn`

error: future cannot be sent between threads safely
   --> /home/den/.cargo/git/checkouts/opentelemetry-rust-e60293f9fcf2de72/9021b4f/opentelemetry-sdk/src/runtime.rs:128:9
    |
128 |         Box::pin(async_std::task::sleep(duration))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future is not `Send`
    |
    = help: within `impl futures_util::Future<Output = ()>`, the trait `std::marker::Send` is not implemented for `*mut u8`
note: future is not `Send` as this value is used across an await
   --> /home/den/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.12.0/src/io/timeout.rs:42:6
    |
40  |           timeout: timer_after(dur),
    |                    ---------------- has type `async_std::utils::timer::Timer` which is not `Send`
41  |           future: f,
42  |       }
    |  ______^
43  | |     .await
    | |__________^ await occurs here, with `timer_after(dur)` maybe used later
44  |   }
    |   - `timer_after(dur)` is later dropped here
    = note: required for the cast from `impl futures_util::Future<Output = ()>` to the object type `dyn futures_util::Future<Output = ()> + std::marker::Send`

error: future cannot be sent between threads safely
   --> /home/den/.cargo/git/checkouts/opentelemetry-rust-e60293f9fcf2de72/9021b4f/opentelemetry-sdk/src/runtime.rs:128:9
    |
128 |         Box::pin(async_std::task::sleep(duration))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future is not `Send`
    |
    = help: the trait `std::marker::Send` is not implemented for `(dyn FnMut() + 'static)`
note: future is not `Send` as this value is used across an await
   --> /home/den/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.12.0/src/io/timeout.rs:42:6
    |
40  |           timeout: timer_after(dur),
    |                    ---------------- has type `async_std::utils::timer::Timer` which is not `Send`
41  |           future: f,
42  |       }
    |  ______^
43  | |     .await
    | |__________^ await occurs here, with `timer_after(dur)` maybe used later
44  |   }
    |   - `timer_after(dur)` is later dropped here
    = note: required for the cast from `impl futures_util::Future<Output = ()>` to the object type `dyn futures_util::Future<Output = ()> + std::marker::Send`

@hdost hdost added this to the Tracing API Stable milestone Nov 12, 2023
@OliverEvans96 OliverEvans96 linked a pull request Sep 2, 2024 that will close this issue
4 tasks
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

Successfully merging a pull request may close this issue.

2 participants