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

instant.elapsed() will panic #2385

Closed
silence-coding opened this issue Jan 3, 2021 · 8 comments
Closed

instant.elapsed() will panic #2385

silence-coding opened this issue Jan 3, 2021 · 8 comments

Comments

@silence-coding
Copy link
Contributor

this method is panic. hyper::client::pool::702
image

image

@silence-coding
Copy link
Contributor Author

image

@seanmonstar
Copy link
Member

Hm. This should never happen, sounds like a bug in libstd.

@silence-coding
Copy link
Contributor Author

I don't think of how to trigger the scene yet, which seems unlikely to happen.

image

@silence-coding
Copy link
Contributor Author

Is the obtained CLOCK_MONOTONIC in multi-core CPU scenarios incorrect?

@silence-coding
Copy link
Contributor Author

Whether to replace elapsed with saturation_duration_since?

@yonip23
Copy link

yonip23 commented Mar 9, 2021

I came across a similar problem once, I think the solution is to use the chrono crate instead.
Anyway, it looks like a bug in Rust: https://stackoverflow.com/questions/64159779/rust-stdtimeinstant-panicked-at-supplied-instant-is-later-than-self

@silence-coding
Copy link
Contributor Author

Whether to replace elapsed with saturation_duration_since?

@seanmonstar Whether hyper will fix this issue, if it is waiting for std to fix it, then I will close the issue.

olix0r added a commit to olix0r/hyper that referenced this issue Jan 31, 2022
We have reports of runtime panics (linkerd/linkerd2#7748) that sound a
lot like rust-lang/rust#86470. We don't have any evidence that these
panics originate in hyper, but hyperium#2385 reports a similar issue.

Even though this is almost definitely a bug in Rust, it seems most
prudent to actively avoid the uses of `Instant` that are prone to this
bug.

This change replaces uses of `Instant::elapsed` and `Instant::sub` with
calls to `Instant::saturating_duration_since` to prevent this class of
panic.
@seanmonstar
Copy link
Member

Fixed in #2746

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

3 participants