Skip to content

"failed at 'sending on a closed channel'" when using Future #14892

Closed
@schmee

Description

@schmee

While playing around with opening a bunch of files and collecting the results I ran into task '<unnamed>' failed at 'sending on a closed channel', C:\bot\slave\nightly-win\build\src\libstd\comm\mod.rs:509 errors. The errors are not deterministic, so sometimes the code works and sometimes not. The error happens with and without -O. Here is a reduced test case:

extern crate sync;
use std::sync::Future;

fn main() {
    let mut futures = range(0, 134).map(|i| {
        Future::spawn(proc() { vec![] } )
    }).collect::<Vec<Future<Vec<String>>>>();
}

Here's another one courtesy of @huonw (this one errors more rarely, at least for me):

extern crate sync;
use std::sync::Future;

fn main() {
    let r = {
        Vec::from_fn(1000, |_| Future::spawn(proc() {}));
    };
}
$ rustc --version
rustc 0.11.0-pre-nightly (18c451f 2014-06-14 06:36:49 +0000)
host: i686-pc-mingw32

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