Skip to content

Conversation

@anrossi
Copy link
Collaborator

@anrossi anrossi commented Nov 18, 2025

Description

Help debug lost reference issues in MsQuic by keeping a global list of streams.

Testing

CI

Documentation

N/A

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.29%. Comparing base (d3d182c) to head (8465cc6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5598      +/-   ##
==========================================
+ Coverage   84.81%   85.29%   +0.47%     
==========================================
  Files          60       60              
  Lines       18647    18658      +11     
==========================================
+ Hits        15816    15914      +98     
+ Misses       2831     2744      -87     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anrossi anrossi marked this pull request as ready for review November 20, 2025 17:20
@anrossi anrossi requested a review from a team as a code owner November 20, 2025 17:20
CxPlatLockInitialize(&MsQuicLib.Lock);
CxPlatDispatchLockInitialize(&MsQuicLib.DatapathLock);
#if DEBUG
CxPlatDispatchLockInitialize(&QuicStreamTrackerLock);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'd suggest simplifying this to one lock for all the trackers.

//
// Global stream object tracker for debugging.
//
CXPLAT_LIST_ENTRY QuicStreamTrackerList = { &QuicStreamTrackerList, &QuicStreamTrackerList };
Copy link
Contributor

Choose a reason for hiding this comment

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

I've never seen this pattern before - is there a precedent for it in MsQuic? If not, let's use the init routine.

#if DEBUG
CXPLAT_DBG_ASSERT(!CxPlatRefDecrement(&Stream->RefTypeBiasedCount[QUIC_STREAM_REF_APP]));
CxPlatDispatchLockAcquire(&QuicStreamTrackerLock);
CxPlatListEntryRemove(&Stream->TrackerLink);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we may want to introduce some abstractions for these trackers, such that if perf becomes a practical bottleneck on debug builds, we can:

  1. Easily add some more fields beyond the list entry
  2. Easily replace the single global list with something more sophisticated, such as a per-CPU list

@guhetier
Copy link
Collaborator

I am not convinced this helps given that AllStreamsLink already exists + the debugger extension. The PR is adding / removing to the list in the exact same spot as for AllStreamsLink. It seems redundant to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants