Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
schmee opened this issue Jun 14, 2014 · 3 comments
Closed

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

schmee opened this issue Jun 14, 2014 · 3 comments

Comments

@schmee
Copy link
Contributor

schmee commented Jun 14, 2014

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
@huonw
Copy link
Member

huonw commented Jun 14, 2014

cc @alexcrichton

@alexcrichton
Copy link
Member

Closing as working as intended. Each future will send the result of its computation along a channel, but what's happening here is that you're spawning a future and the closing the receiving half of the channel by dropping the future. When the task is done it then sends the result on an empty channel, failing the task.

@huonw
Copy link
Member

huonw commented Jun 14, 2014

The user doesn't care that a Future is implemented with channels internally, so I think the failure message should either be specific to Future, or just not be printed at all.

@huonw huonw reopened this Jun 14, 2014
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jun 16, 2014
It's a benign failure that no one needs to know about.

Closes rust-lang#14892
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 5, 2023
MIR episode 6

This PR separates monomorphization from interpreting, and add a monomorphization query to cache the results. Together with making layout queries returning `Arc<Layout>` instead of `Layout` (did you know that `Layout` is a 312 byte struct with a couple of vectors, so it is very costly to clone? I thought it should be very small and cheap) it makes mir interpreting an order of magnitude faster in warmed calls.

It still can't evaluate no test in the r-a repo, but all tests that I tried are hitting rust-lang#7434 so I hope after that it will become able to interpret some real world test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants