membarrier-rs icon indicating copy to clipboard operation
membarrier-rs copied to clipboard

membarrier fails to compile

Open glommer opened this issue 3 years ago • 0 comments

Just got this message when this crate was compiled as part of my dependencies.:

error[E0277]: `*mut c_void` cannot be sent between threads safely
   --> /home/glauber/.cargo/registry/src/github.com-1ecc6299db9ec823/membarrier-0.2.2/src/lib.rs:252:9
    |
252 | /         lazy_static! {
253 | |             /// An alternative solution to `sys_membarrier` that works on older Linux kernels and
254 | |             /// x86/x86-64 systems.
255 | |             static ref BARRIER: Barrier = {
...   |
291 | |             };
292 | |         }
    | |_________^ `*mut c_void` cannot be sent between threads safely
    |
    = help: within `Barrier`, the trait `Send` is not implemented for `*mut c_void`
note: required because it appears within the type `Barrier`
   --> /home/glauber/.cargo/registry/src/github.com-1ecc6299db9ec823/membarrier-0.2.2/src/lib.rs:207:16
    |
207 |         struct Barrier {
    |                ^^^^^^^
    = note: required because of the requirements on the impl of `Sync` for `spin::once::Once<Barrier>`
    = note: required because it appears within the type `lazy_static::lazy::Lazy<Barrier>`
    = note: shared static variables must have a type that implements `Sync`
    = note: this error originates in the macro `__lazy_static_create` (in Nightly builds, run with -Z macro-backtrace for more info)

The error makes sense since Barrier does force-implements Sync, meaning it could be expected to be used in Send situations, but raw pointers are indeed not Send.

glommer avatar Nov 24 '21 19:11 glommer