Skip to content

Missing Send bound in rayon-futures 0.1 #697

@jClaireCodesStuff

Description

@jClaireCodesStuff

ScopeFutureExt::spawn_future should also have Send bounds on the output types of F

<F as Future>::Item: Send,
<F as Future>::Err: Send,

Sync and Send are unsafely derived for ScopeFuture and the comment asserts that the implementation of S is more thread-safe than it appears. However this unsafe impl has the side effect of not checking the other types which are members of ScopeFutureContents, including

result: Poll<CUItem<F>, CUError<F>>,
             ^^^^^^^^^  ?Send but will be sent between threads 

I'm porting rayon-futures to use version 0.3 of the futures crates and found this bug by trying to automatically implement Sync and Send. I haven't yet looked into whether it is safe to assume ScopeHandle: Send (it doesn't feel good - adding that trait bound in rayon-core throws errors), but even assuming it's safe I think it would be better to make that assumption only for the scope: Option<S> field and let the compiler check the rest.

I can't promise that I'll have time to fix this within the next few days, so I'm reporting it for triage. But I'll make at least a simple fix my first priority with whatever time I do find.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions