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

Downloading can panic with "supplied instant is later than self" #8042

Closed
alexcrichton opened this issue Mar 26, 2020 · 4 comments · Fixed by #8114
Closed

Downloading can panic with "supplied instant is later than self" #8042

alexcrichton opened this issue Mar 26, 2020 · 4 comments · Fixed by #8114
Labels
A-networking Area: networking issues, curl, etc. C-bug Category: bug

Comments

@alexcrichton
Copy link
Member

I just saw this happen on CI, where during cargo fetch --locked I saw:

 Downloading crates ...
  Downloaded wat v1.0.12
thread 'main' panicked at 'supplied instant is later than self', src/libstd/time.rs:263:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: failed to download from `https://crates.io/api/v1/crates/clicolors-control/1.0.1/download`

Caused by:
  [42] Operation was aborted by an application callback (Callback aborted)

That's very bad!

Unfortunately this is likely going to be notoriously hard to reproduce and try to fix, but I wanted to open an issue at least as a TODO item to try to audit all time-related tracking in the downloading.

@alexcrichton alexcrichton added the C-bug Category: bug label Mar 26, 2020
@ehuss ehuss added the A-networking Area: networking issues, curl, etc. label Apr 15, 2020
@ehuss
Copy link
Contributor

ehuss commented Apr 15, 2020

It's not clear from the link which job failed (it looks like they ran again), so I'm not sure which platform this was on. I assume it was one of the Linux builders.

I assume this was triggered by this line.

I don't see how updated_at could be in the future. There is this where it is moved forward, but that shouldn't be more than the amount of time elapsed since it was last updated.

The only other thing I can think of is that CLOCK_MONOTONIC was not monotonic. I know in the (distant) past, vm's tended to be buggy where clocks were concerned, but I don't know what the current state of modern VMs is. I assume GitHub actions uses azure's custom hyper-v? Google doesn't reveal any people reporting issues in recent times, so I would assume that is less likely.

@alexcrichton
Copy link
Member Author

Bah sorry I forgot that perma-linking for github actions builds doesn't actually perma-link. If I see this again I'll try to capture more context, but tbh the only other relevant context at the time was probably the Cargo/rustc version, which probably wasn't going to help all that much.

I agree that the likely-ish culprit is a non-monotonic monotonic clock (oxymoron much?). I believe GH actions uses Azure yeah, though.

I've gone ahead and tried to fix that line at least in #8114 and we can try to collect more info in the future if it shows up again.

bors added a commit that referenced this issue Apr 15, 2020
Try to avoid panics on buggy (?) clocks

Try to avoid panics with `Instant` by only performing infallible
operations. This tweaks a comparison located in #8042 to use `Instant`
comparisons rather than `Duration` comparisons which should hopefully
eliminate a source of panics in the face of buggy (maybe?) clocks.

I'm not sure whether this actually fixes the original issue, but seeing
that we have a pretty low chance of the issue recurring, it's probably
fine to go ahead and say...

Closes #8042
@bors bors closed this as completed in be020a5 Apr 15, 2020
@motecshine
Copy link

Linux 5.7.19-2-MANJARO

info: removing previous version of component 'rustc'
warning: during uninstall component rustc was not found
info: removing previous version of component 'cargo'
warning: during uninstall component cargo was not found
info: removing previous version of component 'rust-std'
warning: during uninstall component rust-std was not found
info: removing previous version of component 'rust-docs'
warning: during uninstall component rust-docs was not found
info: removing previous version of component 'rustfmt'
warning: during uninstall component rustfmt was not found
info: removing previous version of component 'clippy'
warning: during uninstall component clippy was not found
info: installing component 'rustc'
info: Defaulting to 500.0 MiB unpack ram
 66.5 MiB /  66.5 MiB (100 %)   8.3 MiB/s in  8s ETA:  0s
info: installing component 'cargo'
info: installing component 'rust-std'
thread 'CloseHandle' panicked at 'supplied instant is later than self', src/libstd/time.rs:263:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1504
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:515
  11: rust_begin_unwind
             at src/libstd/panicking.rs:419
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:111
  13: core::option::expect_failed
             at src/libcore/option.rs:1260
  14: core::option::Option<T>::expect
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libcore/option.rs:347
  15: std::time::Instant::duration_since
             at src/libstd/time.rs:263
  16: <std::time::Instant as core::ops::arith::Sub>::sub
             at src/libstd/time.rs:390
  17: std::time::Instant::elapsed
             at src/libstd/time.rs:327
  18: rustup::diskio::perform
  19: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@alexcrichton
Copy link
Member Author

@motecshine that's a backtrace from rustup, not Cargo.

(and this is the Cargo repository, not rustup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking Area: networking issues, curl, etc. C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants