Skip to content

[CP] Fix double deref in connection pool error path (#5597)#5601

Merged
guhetier merged 2 commits intorelease/2.5from
guhetier/cp_conn_pool_deref
Nov 19, 2025
Merged

[CP] Fix double deref in connection pool error path (#5597)#5601
guhetier merged 2 commits intorelease/2.5from
guhetier/cp_conn_pool_deref

Conversation

@guhetier
Copy link
Collaborator

Description

When creating a connection pool, if a QuicConnStart fails:

  • the connection was marked as ExternalOwner to prevent it from sending notification to the app
  • but this also mean that the closing logic will take care of releasing the owner refcount, since the application is not the owner yet
  • the connection was closed using MsQuicConnectionClose, which release the refcount of the application

This caused a double release, triggering an assertion.

We should not call APIs from internal call (it makes logging confusing and breaks some assumptions), so queue the connection close manually instead.

Fixes #5550.

Testing

C/I.
Need to consider if there is a simple way to deterministically test the connection pool failure paths.

## Description

When creating a connection pool, if a `QuicConnStart` fails:
- the connection was marked as `ExternalOwner` to prevent it from
sending notification to the app
- but this also mean that the closing logic will take care of releasing
the owner refcount, since the application is not the owner yet
- the connection was closed using `MsQuicConnectionClose`, which release
the refcount of the application

This caused a double release, triggering an assertion.

We should not call APIs from internal call (it makes logging confusing
and breaks some assumptions), so queue the connection close manually
instead.

Fixes #5550.

## Testing

C/I.
Need to consider if there is a simply way to deterministically test the
connection pool failure paths.

## Documentation

N/A
@guhetier guhetier requested a review from a team as a code owner November 19, 2025 17:35
anrossi
anrossi previously approved these changes Nov 19, 2025
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 4.54545% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.91%. Comparing base (f11bf0e) to head (2094633).
⚠️ Report is 1 commits behind head on release/2.5.

Files with missing lines Patch % Lines
src/core/connection_pool.c 4.54% 21 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           release/2.5    #5601      +/-   ##
===============================================
+ Coverage        86.17%   86.91%   +0.73%     
===============================================
  Files               59       59              
  Lines            18191    18207      +16     
===============================================
+ Hits             15677    15824     +147     
+ Misses            2514     2383     -131     

☔ 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.

@ProjectsByJackHe ProjectsByJackHe self-requested a review November 19, 2025 20:05
@guhetier guhetier merged commit ac83e94 into release/2.5 Nov 19, 2025
285 checks passed
@guhetier guhetier deleted the guhetier/cp_conn_pool_deref branch November 19, 2025 21:43
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.

4 participants