Skip to content

Potential unsoundness in FuturesUnordered #2786

Closed
@robbie01

Description

@robbie01

I was browsing through the docs for FuturesUnordered when I noticed that its Sync bound is dependent on Fut being Sync rather than Send + Sync. This theoretically allows you to push a value that is !Send + Sync and use poll_next to retrieve it from another thread. Is my understanding of this correct? Apologies for raising an issue if I’m wrong.


Aside: why do FuturesUnordered::<Fut>::iter and the corresponding impl<'a, Fut> IntoIterator for &'a FuturesUnordered<Fut> require Fut: Unpin? That requirement can be circumvented safely via e.g. Pin::new(&f).iter_pin_ref().map(Pin::get_ref).

Aside aside: why do iter_pin_ref and iter_pin_mut require it to be pinned? FuturesUnordered implements Unpin unconditionally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions