Skip to content

stdlib is instantiating Arc<T> with T's that are not Send+Sync #23584

Closed
@pnkfelix

Description

@pnkfelix

From arc.rs, we have:

impl<T: Sync + Send> Drop for Arc<T> { ... }

From thread.rs, we have:

struct Packet<T>(Arc<UnsafeCell<Option<Result<T>>>>);

And, for completeness, from cell.rs, we have:

impl<T> !Sync for UnsafeCell<T> {}

This is bad. The Drop method of Arc gets to assume that T adheres to the stated bounds, but Packet is violating that promise. (The current Rust implementation just blindly emits a Drop impl and invokes it; so presumably the invariants of Arc itself are maintained, but the global invariants of the system need not be.)

We have not been checking for this; such a check is the task described in #8142.

But we need to fix this; certainly as long as it is the case, the planned implementation of #8142 cannot land.

cc @alexcrichton @aturon @nikomatsakis

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