Skip to content

Use clock BOOTTIME for thread::sleep on linux #113513

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
wants to merge 1 commit into from
Closed

Use clock BOOTTIME for thread::sleep on linux #113513

wants to merge 1 commit into from

Conversation

dvdsk
Copy link
Contributor

@dvdsk dvdsk commented Jul 9, 2023

Thread::sleep uses nanosleep. Nanosleep uses the MONOTONIC clock. That clock does not take suspend time into account. Since kernel commit d6ed449 the MONOTONIC clock behaves the same as the BOOTTIME clock. The BOOTTIME clock does count time spend suspended.

Kernel commit d6ed449 was merged somewhere between v4.14 and v4.19. Rust supports kernels before and after that.

This commit changes sleep to use the BOOTTIME clock on linux targes. This makes sleep behave consistently on linux regardless of kernel version.


I discovered this while preparing the implementation for rust-lang/libs-team#237. Fixing it changes behavior of rust code on older kernel versions and could therefore be seen as breaking. Since the kernel also broke behavior the same way I think it might be okay.

A proposal (#88714) to switch to the BOOTTIME clock for Instant ran into trouble as the minimally supported linux kernel did no support BOOTTIME. Since then the minimal kernel version has been increased and this is no longer an issue.

It might be useful to re-evaluate that given the change made in kernel commit d6ed449. Lets however first look at sleep before we open that can of worms.

I think this change is small and simple enough for a PR if its not let me know and I'll move it to a libs team RFC.


Sources:

Thread::sleep uses nanosleep. Nanosleep uses the MONOTONIC clock.
That clock does not take suspend time into account. Since kernel commit
d6ed449 the MONOTONIC clock behaves the same as the BOOTTIME clock.
The BOOTTIME clock does count time spend suspended.

Commit d6ed449 was merged somewhere between v4.14 and v4.19. Rust supports
kernels before and after that.

This commit changes sleep to use the BOOTTIME clock on linux targes.
This makes sleep behave consistently on linux regardless of kernel
version.
@rustbot
Copy link
Collaborator

rustbot commented Jul 9, 2023

r? @cuviper

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 9, 2023
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[group]Run git config --global core.autocrlf false
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
---
  lfs: false
  submodules: false
  set-safe-directory: true
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
---
##[group]Run src/ci/scripts/setup-environment.sh
src/ci/scripts/setup-environment.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
---
##[group]Run src/ci/scripts/should-skip-this.sh
src/ci/scripts/should-skip-this.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
---
##[group]Run src/ci/scripts/verify-channel.sh
src/ci/scripts/verify-channel.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: x86_64-gnu-tools
##[endgroup]
##[group]Run src/ci/scripts/collect-cpu-stats.sh
src/ci/scripts/collect-cpu-stats.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
---
##[group]Run src/ci/scripts/install-sccache.sh
src/ci/scripts/install-sccache.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: x86_64-gnu-tools
##[endgroup]
##[group]Run src/ci/scripts/select-xcode.sh
src/ci/scripts/select-xcode.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: x86_64-gnu-tools
##[endgroup]
##[group]Run src/ci/scripts/install-clang.sh
src/ci/scripts/install-clang.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: x86_64-gnu-tools
##[endgroup]
##[group]Run src/ci/scripts/install-wix.sh
src/ci/scripts/install-wix.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: x86_64-gnu-tools
##[endgroup]
##[group]Run src/ci/scripts/disable-git-crlf-conversion.sh
src/ci/scripts/disable-git-crlf-conversion.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
---
##[group]Run src/ci/scripts/install-msys2.sh
src/ci/scripts/install-msys2.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: x86_64-gnu-tools
##[endgroup]
##[group]Run src/ci/scripts/install-mingw.sh
src/ci/scripts/install-mingw.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: x86_64-gnu-tools
##[endgroup]
##[group]Run src/ci/scripts/install-ninja.sh
src/ci/scripts/install-ninja.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: x86_64-gnu-tools
##[endgroup]
##[group]Run src/ci/scripts/enable-docker-ipv6.sh
src/ci/scripts/enable-docker-ipv6.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
---
##[group]Run src/ci/scripts/disable-git-crlf-conversion.sh
src/ci/scripts/disable-git-crlf-conversion.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: x86_64-gnu-tools
##[endgroup]
##[group]Run src/ci/scripts/verify-line-endings.sh
src/ci/scripts/verify-line-endings.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: x86_64-gnu-tools
##[endgroup]
##[group]Run src/ci/scripts/verify-backported-commits.sh
src/ci/scripts/verify-backported-commits.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
---
##[group]Run src/ci/scripts/verify-stable-version-number.sh
src/ci/scripts/verify-stable-version-number.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
---
##[group]Run src/ci/scripts/run-build-from-ci.sh
src/ci/scripts/run-build-from-ci.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
  HEAD_SHA: 0a668ba1fec51eb1563d91a6387bb61ea687cb17
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
---
## Running ui tests in tests/pass against miri for x86_64-unknown-linux-gnu
   Compiler: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/miri "--error-format=json" "-Dwarnings" "-Dunused" "-Zui-testing" "--target" "x86_64-unknown-linux-gnu" "--out-dir" OUT_DIR
.................................................................................................... 100
........................................................................i........................... 200
..iiii..............................................F...F........FF................................. 300
....F...
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Zui-testing" "--target" "x86_64-unknown-linux-gnu" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui" "tests/pass/shims/sleep_long.rs" "-Zmiri-ignore-leaks" "-Zmiri-disable-isolation" "--edition" "2021"





pass test got exit status: 1, but expected 0

actual output differed from expected
Execute `./miri bless` to update `tests/pass/shims/sleep_long.stderr` to the actual output
+++ <stderr output>
+++ <stderr output>
+error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
+   |
+   |
+LL |                 let ret = libc::clock_nanosleep(libc::CLOCK_BOOTTIME, 0, ts_ptr, ts_ptr);
+   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `clock_nanosleep` on OS `linux`
+   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
+   = note: BACKTRACE:
+   = note: inside `std::sys::PLATFORM::thread::Thread::sleep` at RUSTLIB/std/src/sys/PLATFORM/thread.rs:LL:CC
+   = note: inside `std::thread::sleep` at RUSTLIB/std/src/thread/mod.rs:LL:CC
+   = note: inside `std::thread::sleep` at RUSTLIB/std/src/thread/mod.rs:LL:CC
+note: inside `main`
+  --> $DIR/sleep_long.rs:LL:CC
+   |
+LL |     thread::sleep(Duration::from_millis(100));
+
+note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
+
+error: aborting due to previous error
+error: aborting due to previous error
+
+


There were 1 unmatched diagnostics that occurred outside the testfile and had no pattern
    Error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
full stderr:
full stderr:
error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
   |
   |
LL |                 let ret = libc::clock_nanosleep(libc::CLOCK_BOOTTIME, 0, ts_ptr, ts_ptr);
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `clock_nanosleep` on OS `linux`
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
   = note: BACKTRACE:
   = note: inside `std::sys::unix::thread::Thread::sleep` at /checkout/library/std/src/sys/unix/thread.rs:241:27: 241:89
   = note: inside `std::thread::sleep` at /checkout/library/std/src/thread/mod.rs:872:5: 872:28
   = note: inside `std::thread::sleep` at /checkout/library/std/src/thread/mod.rs:872:5: 872:28
note: inside `main`
  --> tests/pass/shims/sleep_long.rs:14:5
   |
LL |     thread::sleep(Duration::from_millis(100));

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error
---

pass test got exit status: 1, but expected 0

actual output differed from expected
Execute `./miri bless` to update `tests/pass/shims/time.stderr` to the actual output
+++ <stderr output>
+++ <stderr output>
+error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
+   |
+   |
+LL |                 let ret = libc::clock_nanosleep(libc::CLOCK_BOOTTIME, 0, ts_ptr, ts_ptr);
+   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `clock_nanosleep` on OS `linux`
+   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
+   = note: BACKTRACE:
+   = note: inside `std::sys::PLATFORM::thread::Thread::sleep` at RUSTLIB/std/src/sys/PLATFORM/thread.rs:LL:CC
+   = note: inside `std::thread::sleep` at RUSTLIB/std/src/thread/mod.rs:LL:CC
+   = note: inside `std::thread::sleep` at RUSTLIB/std/src/thread/mod.rs:LL:CC
+note: inside `test_sleep`
+  --> $DIR/time.rs:LL:CC
+   |
+LL |     std::thread::sleep(Duration::from_millis(100));
+note: inside `main`
+  --> $DIR/time.rs:LL:CC
+   |
+LL |     test_sleep();
---
+


There were 1 unmatched diagnostics that occurred outside the testfile and had no pattern
    Error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
full stderr:
full stderr:
error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
   |
   |
LL |                 let ret = libc::clock_nanosleep(libc::CLOCK_BOOTTIME, 0, ts_ptr, ts_ptr);
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `clock_nanosleep` on OS `linux`
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
   = note: BACKTRACE:
   = note: inside `std::sys::unix::thread::Thread::sleep` at /checkout/library/std/src/sys/unix/thread.rs:241:27: 241:89
   = note: inside `std::thread::sleep` at /checkout/library/std/src/thread/mod.rs:872:5: 872:28
   = note: inside `std::thread::sleep` at /checkout/library/std/src/thread/mod.rs:872:5: 872:28
note: inside `test_sleep`
  --> tests/pass/shims/time.rs:13:5
   |
LL |     std::thread::sleep(Duration::from_millis(100));
note: inside `main`
  --> tests/pass/shims/time.rs:51:5
   |
LL |     test_sleep();
---




tests/pass/concurrency/sync.rs (revision `stack`) FAILED:
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Zui-testing" "--target" "x86_64-unknown-linux-gnu" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui" "tests/pass/concurrency/sync.rs" "--cfg=stack" "-Zmiri-disable-isolation" "-Zmiri-strict-provenance" "--edition" "2021"





pass test got exit status: 1, but expected 0

actual output differed from expected
Execute `./miri bless` to update `tests/pass/concurrency/sync.stack.stderr` to the actual output
--- tests/pass/concurrency/sync.stack.stderr
+++ <stderr output>
+error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
+   |
+   |
+LL |                 let ret = libc::clock_nanosleep(libc::CLOCK_BOOTTIME, 0, ts_ptr, ts_ptr);
+   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `clock_nanosleep` on OS `linux`
+   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
+   = note: BACKTRACE:
+   = note: inside `std::sys::PLATFORM::thread::Thread::sleep` at RUSTLIB/std/src/sys/PLATFORM/thread.rs:LL:CC
+   = note: inside `std::thread::sleep` at RUSTLIB/std/src/thread/mod.rs:LL:CC
+   = note: inside `std::thread::sleep` at RUSTLIB/std/src/thread/mod.rs:LL:CC
+note: inside closure
+  --> $DIR/sync.rs:LL:CC
+   |
+LL |         thread::sleep(Duration::from_millis(200));
+
+note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
+
+error: aborting due to previous error
+error: aborting due to previous error
+
+


actual output differed from expected
Execute `./miri bless` to update `tests/pass/concurrency/sync.stack.stdout` to the actual output
--- tests/pass/concurrency/sync.stack.stdout
-before wait
-before wait
-before wait
-before wait
---
-after wait


There were 1 unmatched diagnostics that occurred outside the testfile and had no pattern
    Error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
full stderr:
full stderr:
error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
   |
   |
LL |                 let ret = libc::clock_nanosleep(libc::CLOCK_BOOTTIME, 0, ts_ptr, ts_ptr);
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `clock_nanosleep` on OS `linux`
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
   = note: BACKTRACE:
   = note: inside `std::sys::unix::thread::Thread::sleep` at /checkout/library/std/src/sys/unix/thread.rs:241:27: 241:89
   = note: inside `std::thread::sleep` at /checkout/library/std/src/thread/mod.rs:872:5: 872:28
   = note: inside `std::thread::sleep` at /checkout/library/std/src/thread/mod.rs:872:5: 872:28
note: inside closure
  --> tests/pass/concurrency/sync.rs:214:9
   |
LL |         thread::sleep(Duration::from_millis(200));

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error
error: aborting due to previous error




tests/pass/concurrency/sync.rs (revision `tree`) FAILED:
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Zui-testing" "--target" "x86_64-unknown-linux-gnu" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui" "tests/pass/concurrency/sync.rs" "--cfg=tree" "-Zmiri-tree-borrows" "-Zmiri-disable-isolation" "-Zmiri-strict-provenance" "--edition" "2021"





pass test got exit status: 1, but expected 0

actual output differed from expected
Execute `./miri bless` to update `tests/pass/concurrency/sync.tree.stderr` to the actual output
--- tests/pass/concurrency/sync.tree.stderr
+++ <stderr output>
+error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
+   |
+   |
+LL |                 let ret = libc::clock_nanosleep(libc::CLOCK_BOOTTIME, 0, ts_ptr, ts_ptr);
+   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `clock_nanosleep` on OS `linux`
+   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
+   = note: BACKTRACE:
+   = note: inside `std::sys::PLATFORM::thread::Thread::sleep` at RUSTLIB/std/src/sys/PLATFORM/thread.rs:LL:CC
+   = note: inside `std::thread::sleep` at RUSTLIB/std/src/thread/mod.rs:LL:CC
+   = note: inside `std::thread::sleep` at RUSTLIB/std/src/thread/mod.rs:LL:CC
+note: inside closure
+  --> $DIR/sync.rs:LL:CC
+   |
+LL |         thread::sleep(Duration::from_millis(200));
+
+note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
+
+error: aborting due to previous error
+error: aborting due to previous error
+
+


actual output differed from expected
Execute `./miri bless` to update `tests/pass/concurrency/sync.tree.stdout` to the actual output
--- tests/pass/concurrency/sync.tree.stdout
-before wait
-before wait
-before wait
-before wait
---
-after wait


There were 1 unmatched diagnostics that occurred outside the testfile and had no pattern
    Error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
full stderr:
full stderr:
error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
   |
   |
LL |                 let ret = libc::clock_nanosleep(libc::CLOCK_BOOTTIME, 0, ts_ptr, ts_ptr);
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `clock_nanosleep` on OS `linux`
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
   = note: BACKTRACE:
   = note: inside `std::sys::unix::thread::Thread::sleep` at /checkout/library/std/src/sys/unix/thread.rs:241:27: 241:89
   = note: inside `std::thread::sleep` at /checkout/library/std/src/thread/mod.rs:872:5: 872:28
   = note: inside `std::thread::sleep` at /checkout/library/std/src/thread/mod.rs:872:5: 872:28
note: inside closure
  --> tests/pass/concurrency/sync.rs:214:9
   |
LL |         thread::sleep(Duration::from_millis(200));

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error
---

pass test got exit status: 1, but expected 0

actual output differed from expected
Execute `./miri bless` to update `tests/pass/shims/time-with-isolation.stderr` to the actual output
+++ <stderr output>
+++ <stderr output>
+error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
+   |
+   |
+LL |                 let ret = libc::clock_nanosleep(libc::CLOCK_BOOTTIME, 0, ts_ptr, ts_ptr);
+   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `clock_nanosleep` on OS `linux`
+   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
+   = note: BACKTRACE:
+   = note: inside `std::sys::PLATFORM::thread::Thread::sleep` at RUSTLIB/std/src/sys/PLATFORM/thread.rs:LL:CC
+   = note: inside `std::thread::sleep` at RUSTLIB/std/src/thread/mod.rs:LL:CC
+   = note: inside `std::thread::sleep` at RUSTLIB/std/src/thread/mod.rs:LL:CC
+note: inside `test_sleep`
+  --> $DIR/time-with-isolation.rs:LL:CC
+   |
+LL |     std::thread::sleep(Duration::from_secs(3600));
+note: inside `main`
+  --> $DIR/time-with-isolation.rs:LL:CC
+   |
+LL |     test_sleep();
---
+


There were 1 unmatched diagnostics that occurred outside the testfile and had no pattern
    Error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
full stderr:
full stderr:
error: unsupported operation: can't call foreign function `clock_nanosleep` on OS `linux`
   |
   |
LL |                 let ret = libc::clock_nanosleep(libc::CLOCK_BOOTTIME, 0, ts_ptr, ts_ptr);
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `clock_nanosleep` on OS `linux`
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
   = note: BACKTRACE:
   = note: inside `std::sys::unix::thread::Thread::sleep` at /checkout/library/std/src/sys/unix/thread.rs:241:27: 241:89
   = note: inside `std::thread::sleep` at /checkout/library/std/src/thread/mod.rs:872:5: 872:28
   = note: inside `std::thread::sleep` at /checkout/library/std/src/thread/mod.rs:872:5: 872:28
note: inside `test_sleep`
  --> tests/pass/shims/time-with-isolation.rs:6:5
   |
LL |     std::thread::sleep(Duration::from_secs(3600));
note: inside `main`
  --> tests/pass/shims/time-with-isolation.rs:43:5
   |
LL |     test_sleep();
---
test result: FAIL. 5 tests failed, 298 tests passed, 5 ignored, 0 filtered out
Error: 
   0: tests failed

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/compiletest-df477730afced097 --quiet` (exit status: 1)
Build completed unsuccessfully in 0:01:46

@the8472
Copy link
Member

the8472 commented Jul 9, 2023

Since kernel commit d6ed449 the MONOTONIC clock behaves the same as the BOOTTIME clock.

That's wrong. It was reverted shortly after in torvalds/linux@a3ed0e4

@dvdsk
Copy link
Contributor Author

dvdsk commented Jul 9, 2023

Since kernel commit d6ed449 the MONOTONIC clock behaves the same as the BOOTTIME clock.

That's wrong. It was reverted shortly after in torvalds/linux@a3ed0e4

I missed that, thanks a lot! No need for this then.

@dvdsk dvdsk closed this Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants