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

Mysterious runtime failures when chaining methods on a Timer #14714

Closed
dmanescu opened this issue Jun 7, 2014 · 3 comments · Fixed by #14745
Closed

Mysterious runtime failures when chaining methods on a Timer #14714

dmanescu opened this issue Jun 7, 2014 · 3 comments · Fixed by #14745

Comments

@dmanescu
Copy link
Contributor

dmanescu commented Jun 7, 2014

In timer.rs:

use std::io::timer::Timer;

fn main(){
    let wait: Receiver<()> = Timer::new().unwrap().oneshot(5000);
    wait.recv();
}

Result:

task '<main>' failed at 'Box<Any>', /path/to/rust/src/libstd/comm/mod.rs:763

Unchaining the oneshot method call results in normal behaviour.

@huonw huonw added the A-libs label Jun 7, 2014
@huonw
Copy link
Member

huonw commented Jun 7, 2014

I see:

task '<main>' failed at 'receiving on a closed channel', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libstd/comm/mod.rs:763

This isn't really a bug in my mind, but it is quite surprising and it would be nice if there was some way to assist programmers by indicating that chaining directly onto a Timer doesn't do what you expect/want (specifically, the Timer object is dropped at the end of the statement, which destroys the other end of the channel, meaning recv will always fail).

@alexcrichton
Copy link
Member

This is indeed expected, and documented, but I am surprised that the error message you are seeing is Box<Any> as opposed to receiving on a closed channel. Can you describe how you compiled this code and how you compiled the compiler?

@dmanescu
Copy link
Contributor Author

dmanescu commented Jun 8, 2014

I am using luqman's most recent build for arm-linux-androideabi. I am just compiling with rustc timer.rs && ./timer.
I'm not sure if it's relevant but I am using a rather dodgy cc called by rust to link the executable (my toolchain is GCC 4.4.0 - i.e. extremely old - but this causes linker errors due to missing symbols in libgcc, which I fixed by pasting in libgcc.a and libgcc_eh.a from a 4.6.0 toolchain).

huonw added a commit to huonw/rust that referenced this issue Jun 8, 2014
bors added a commit that referenced this issue Jun 8, 2014
std::io: expand the oneshot/periodic docs.

Examples!

Fixes #14714.
mcpherrinm pushed a commit to mcpherrinm/rust that referenced this issue Jun 10, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 5, 2023
…o-actions, r=Veykril

fix: ide: exclude sized in go-to actions in hover

fixes rust-lang#13163

i opted to just simply omit `Sized` entirely from go-to actions, as opposed to including it if even someone writes an explicit `T: Sized`, as i think a go-to on Sized is of dubious value practically.
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