Skip to content

Failling assertion in oneshot abort_selection with native threads. #12802

Closed
@ghost

Description

The exact assert I am seeing fail is:

task '<unnamed>' failed at 'assertion failed: self.data.is_none()', /build/buildd/rust-nightly-201403090405~e1681df~precise/src/libstd/comm/oneshot.rs:346

If a task waits on a select and one of the channels is new (still in OneShot mode), and that channel is sent two messages before the other task is scheduled. This assertion will be triggered.

Code to reproduce:

extern crate native;

use std::io::timer::Timer;
use std::comm::{Chan, Select};

#[start]
fn start(argc: int, argv: **u8) -> int {
    native::start(argc, argv, main)
}

fn select_task(p: &Port<()>)
{
    let mut timer = Timer::new().unwrap();

    timer.sleep(25);

    let select = Select::new();
    let mut handle = select.handle(p);
    unsafe {handle.add()};

    let _ = select.wait();
    return;
}

fn main()
{
    let mut timer = Timer::new().unwrap();

    let (p, c) = Chan::new();
    spawn(proc() {
        select_task(&p)
    });

    timer.sleep(50);
    c.send(());
    c.send(());
}

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