tokio/interval: Fix overflow for interval tick#7193
Open
lexnv wants to merge 4 commits intotokio-rs:masterfrom
Open
tokio/interval: Fix overflow for interval tick#7193lexnv wants to merge 4 commits intotokio-rs:masterfrom
lexnv wants to merge 4 commits intotokio-rs:masterfrom
Conversation
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Darksonn
reviewed
Mar 4, 2025
Member
|
Thanks for the PR. Please add a test that would have caught this. |
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Author
|
Thanks for the swift review! 🙏 I've added a test and patched the missed tick behavior as well |
Darksonn
reviewed
Mar 4, 2025
| } | ||
|
|
||
| #[tokio::test(start_paused = true)] | ||
| #[tokio::test] |
Member
There was a problem hiding this comment.
Why can't this test use start_paused?
Author
There was a problem hiding this comment.
We need a bit of delay between two subsequent poll_tick calls (5ms) to enter the misstick behavior and trigger the overflow panic
Member
There was a problem hiding this comment.
In general, a test that takes 2 seconds to complete is not acceptable. I'm quite certain that the test works just fine with start_paused - the parameter should not change the behavior of tests that rely on time other than making them run faster.
Member
|
Hi @lexnv, are you still working on this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an overflow produced by the
Instant::poll_tickfunction when called for an instant set with a period fromu64::MAX.For example, timers initiated like the following would panic because there's no room to add the 5 ms duration:
cc paritytech/polkadot-sdk#7793