Skip to content

Overflow in mpsc::Sender::clone leads to illegal instruction #35847

@apasel422

Description

@apasel422

The following crashes with an illegal instruction when compiled in release mode with 1.13.0-nightly (499484f56 2016-08-18) on i686-unknown-linux-gnu:

fn main() {
    let (tx, _) = std::sync::mpsc::channel::<()>();

    for _ in 0..std::usize::MAX {
        std::mem::forget(tx.clone());
    }
}

It's presumably the result of the unchecked addition in std::sync::mpsc::shared::Packet::clone_chan. Another unchecked addition is performed in std::sync::mpsc::sync::Packet::clone_chan, and other uses of fetch_add in the mpsc module should probably be audited as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-help-wantedCall for participation: Help is requested to fix this issue.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.P-mediumMedium priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions