Skip to content

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

Closed
@cjcole

Description

@cjcole
$ 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));
}

$ 

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