Skip to content

std::thread::sleep(Duration::new(u64::MAX, 0)) panics with EINVAL #34330

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

Closed
cjcole opened this issue Jun 17, 2016 · 0 comments
Closed

std::thread::sleep(Duration::new(u64::MAX, 0)) panics with EINVAL #34330

cjcole opened this issue Jun 17, 2016 · 0 comments

Comments

@cjcole
Copy link

cjcole commented Jun 17, 2016

$ cargo version
cargo 0.10.0-nightly (10ddd7d 2016-04-08)

$ rustc --version --verbose
rustc 1.9.0 (e4e8b6668 2016-05-18)
binary: rustc
commit-hash: e4e8b666850a763fdf1c3c2c142856ab51e32779
commit-date: 2016-05-18
host: x86_64-apple-darwin
release: 1.9.0

$ export RUST_BACKTRACE=1 cargo clean && cargo run
     Running `target/debug/sleeptest`
thread '<main>' panicked at 'assertion failed: `(left == right)` (left: `22`, right: `4`)', ../src/libstd/sys/unix/thread.rs:137
stack backtrace:
   1:        0x10f6c4058 - std::sys::backtrace::tracing::imp::write::h4c73fcd3363076f5
   2:        0x10f6c55c5 - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h0422dbb3077e6747
   3:        0x10f6c51fe - std::panicking::default_hook::haac48fa641db8fa2
   4:        0x10f6c01c6 - std::sys_common::unwind::begin_unwind_inner::h39d40f52add53ef7
   5:        0x10f6c095e - std::sys_common::unwind::begin_unwind_fmt::h64c0ff793199cc1b
   6:        0x10f6bf79c - std::thread::sleep::ha8d8975d57b519ae
   7:        0x10f6bf242 - sleeptest::main::hda16ced47dcbd1e7
   8:        0x10f6c4df2 - std::sys_common::unwind::try::try_fn::h09ba69fd13531e58
   9:        0x10f6c343b - __rust_try
  10:        0x10f6c4c34 - std::rt::lang_start::h5b0863080165c75e
  11:        0x10f6bf309 - main
error: Process didn't exit successfully: `target/debug/sleeptest` (exit code: 101)

$ cat src/main.rs
use std::time::Duration;
use std::u64;

fn main() {
    std::thread::sleep(Duration::new(u64::MAX, 0));
}

$ 
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 22, 2016
Fix overflow error in thread::sleep

Fixes rust-lang#34330

I added a test to have a more clear error inside the function. Since `time_t` is `i64` and we expect `u64`, maybe we should changed the awaited type?
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 22, 2016
Fix overflow error in thread::sleep

Fixes rust-lang#34330

I added a test to have a more clear error inside the function. Since `time_t` is `i64` and we expect `u64`, maybe we should changed the awaited type?
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

No branches or pull requests

2 participants