-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix PeriodicTimer_ActiveOperations_TimerRooted test #68805
Merged
Merged
Conversation
This file contains 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
There are two problems with this test 1. `WaitForNextTickAsync` may return a synchronously completed task, in which case it does not root the timer, causing our first `WaitForTimerToBeCollected` to fail because the timer was collected. This problem is easily reproduced by adding a small sleep after constructing the `PeriodicTimer` in `Create`, and I believe it is the cause of dotnet#59542. 2. There is no guarantee that the timer is not still rooted after the wait finishes because the returned `ValueTask<bool>` may be keeping it alive. This is unlikely since Roslyn should not extend the lifetime of the `ValueTask<bool>` like this across the await, but I have introduced another method just to be safe. Fix dotnet#59542
Tagging subscribers to this area: @mangod9 Issue DetailsThere are two problems with this test
Fix #59542
|
stephentoub
reviewed
May 3, 2022
src/libraries/System.Runtime/tests/System/Threading/PeriodicTimerTests.cs
Show resolved
Hide resolved
stephentoub
approved these changes
May 3, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change, otherwise LGTM. Thanks!
…merTests.cs Co-authored-by: Stephen Toub <[email protected]>
danmoseley
reviewed
May 3, 2022
src/libraries/System.Runtime/tests/System/Threading/PeriodicTimerTests.cs
Outdated
Show resolved
Hide resolved
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
There are two problems with this test
WaitForNextTickAsync
may return a synchronously completed task, inwhich case it does not root the timer, causing our first
WaitForTimerToBeCollected
to fail because the timer was collected.This problem is easily reproduced by adding a small sleep after
constructing the
PeriodicTimer
inCreate
, and I believe it is thecause of System.Threading.Tests.PeriodicTimerTests.PeriodicTimer_ActiveOperations_TimerRooted failing in CI #59542.
wait finishes because the returned
ValueTask<bool>
may be keepingit alive (although, it seems unlikely Roslyn will extend the lifetime across the
await
like this).Fixed by wrapping in another NoInlining method.
Fix #59542