Fix ServerAcceptContext smart pointer handling and lifetime#6125
Merged
Conversation
ServerAcceptContext stored its connection as a raw TestConnection** and was initialized by casting a UniquePtr<TestConnection> to a raw pointer. The smart pointer was also declared after the TestListener, giving it a shorter lifetime than the listener that references it through its context. - Change ServerAcceptContext::NewConnection to UniquePtr<TestConnection>* and pass the smart pointer directly (no cast). - Manage the accepted connection through reset() in the accept callbacks instead of raw assignment/delete. - Move each Server declaration before its TestListener so the connection outlives the listener. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6125 +/- ##
==========================================
- Coverage 86.03% 85.40% -0.64%
==========================================
Files 60 60
Lines 18911 18911
==========================================
- Hits 16271 16151 -120
- Misses 2640 2760 +120 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
anrossi
approved these changes
Jul 1, 2026
guhetier
added a commit
that referenced
this pull request
Jul 1, 2026
Now that #6125 changed ServerAcceptContext to take a UniquePtr<TestConnection>*, pass &Server directly instead of casting to TestConnection**. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Description
ServerAcceptContextstored its connection as a rawTestConnection**and was initialized by casting aUniquePtr<TestConnection>to a raw pointer. The smart pointer was also declared after theTestListener, giving it a shorter lifetime than the listener that references it through its context.ServerAcceptContext::NewConnectiontoUniquePtr<TestConnection>*and pass the smart pointer directly (no cast).reset()in the accept callbacks instead of raw assignment/delete.Serverdeclaration before itsTestListenerso the connection outlives the listener.Testing
Test-only change; covered by existing handshake/data/datagram tests. Built
testliblocally with no errors.Documentation
No documentation impact.