Skip to content

Thread crashes if Receiver is used #17308

@vhbit

Description

@vhbit

Here is a test case:

use std::rt::thread::Thread;

fn write_loop(rx: Receiver<uint>) {
    loop {
        match rx.recv_opt() {
            Ok(v) => println!("v {}", v),
            _ => break
        }
    }
}

fn main() {
    let (tx, rx) = channel();
    Thread::start(proc() {
        write_loop(rx);
    });

    tx.send(3u);
}

Output: fatal runtime error: assertion failed: !ptr.is_null()

I guess that's because there is no Task associated with thread and while it is possible to create a task manually - there is no known for me way to put Runtime into it.

Considering there is no direct way to guess what for this thread is created and whether it should use native runtime or not, it is reasonable. But it is still quite unexpected, so I believe there should be either a way to put runtime into it or documentation of Receiver should note that more clearly.

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