Skip to content

Conversation

@kornelpal
Copy link
Contributor

Add test for multiplexer GC rooting in #2413.


// Use sync wait and sleep to ensure a more timely GC
Task.WaitAny(startGC.Task, testTask);
while (!testTask.IsCompleted)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth a timeout exit failure condition here, perhaps after N iterations for some N

Also, to check that it hasn't been collected: really, you need to ask a WeakReference? The test is fine, just: we're not directly testing whether it has been collected - we're testing whether the task completed. These are causally related, sure; but if the test name says it is checking collection: we should probably actually check for collection. Or rename the test.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 tests where failure is hanging forever cause a lot of pain :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that testTask actually has a timeout via WithTimeout, and without the GC rooting fix this test times out.

Unless you have some good idea, I'll likely just rename the test because a WeakReference could be used to confirm that the multiplexer is not collected before the ping completes, but could not be used to confirm that it was not collected after that as the GC was free to collect it, and this would require a lot of extra code to avoid strong references.

On the other hand because of the strong reference in using in the body of testTask, the task completing implies that the connection was still alive. I'll add a comment about this at the end of testTask.

@NickCraver NickCraver deleted the branch StackExchange:marc/fix-rooting March 29, 2023 11:44
@NickCraver NickCraver closed this Mar 29, 2023
@NickCraver
Copy link
Collaborator

NickCraver commented Mar 29, 2023

Ohhhh, now I get what Marc meant - this was against the other branch not main. Didn't meant to drop this!

@kornelpal I'd like to reopen this targeting main when you can!

@kornelpal
Copy link
Contributor Author

Sure, I'll reopen it after pushing some improvements. Note that this needs to be merged after #2408 so that the test is not failing.

@mgravell
Copy link
Collaborator

mgravell commented Mar 29, 2023 via email

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

Successfully merging this pull request may close these issues.

3 participants