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

FutureExt::timeout panics on Duration::MAX #979

Open
jocutajar opened this issue Jul 22, 2021 · 1 comment
Open

FutureExt::timeout panics on Duration::MAX #979

jocutajar opened this issue Jul 22, 2021 · 1 comment

Comments

@jocutajar
Copy link

Ahoj!

This:

async_std::future::pending::<()>()
        .timeout(Duration::MAX)
        .await?;

Panics:

thread 'main' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:374:33

Proposal: use some form of saturating or checked add.

Many thanks, Yo

Trace:

0: rust_begin_unwind
at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:493:5
1: core::panicking::panic_fmt
at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/panicking.rs:92:14
2: core::option::expect_failed
at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/option.rs:1241:5
3: core::option::Option::expect
at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/option.rs:349:21
4: <std::time::Instant as core::ops::arith::Addcore::time::Duration>::add
at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/time.rs:374:9
5: async_io::Timer::after
at /home/robert/.cargo/registry/src/github.com-1ecc6299db9ec823/async-io-1.6.0/src/lib.rs:158:19
6: async_std::utils::timer_after
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/utils.rs:72:5
7: async_std::future::timeout::TimeoutFuture::new
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/future/timeout.rs:54:20
8: async_std::future::future::FutureExt::timeout
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/future/future/mod.rs:393:13
9: samotop_server::main_fut::{{closure}}
at ./src/main.rs:136:5

@zhuxiujia
Copy link

Ahoj!

This:

async_std::future::pending::<()>()
        .timeout(Duration::MAX)
        .await?;

Panics:

thread 'main' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:374:33

Proposal: use some form of saturating or checked add.

Many thanks, Yo

Trace:

0: rust_begin_unwind
at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:493:5
1: core::panicking::panic_fmt
at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/panicking.rs:92:14
2: core::option::expect_failed
at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/option.rs:1241:5
3: core::option::Option::expect
at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/option.rs:349:21
4: <std::time::Instant as core::ops::arith::Addcore::time::Duration>::add
at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/time.rs:374:9
5: async_io::Timer::after
at /home/robert/.cargo/registry/src/github.com-1ecc6299db9ec823/async-io-1.6.0/src/lib.rs:158:19
6: async_std::utils::timer_after
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/utils.rs:72:5
7: async_std::future::timeout::TimeoutFuture::new
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/future/timeout.rs:54:20
8: async_std::future::future::FutureExt::timeout
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/future/future/mod.rs:393:13
9: samotop_server::main_fut::{{closure}}
at ./src/main.rs:136:5

I'm worried that Async_STD doesn't commit code anymore

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