← Back to Pull requests

UCT/TCP/SOCKCM: Close pending server endpoints on listener destroy #12465

Open
unknown opened this pull request with 222 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 24, 2026 22:27 UTC
Author

What?


When a TCP sockcm listener is destroyed, close the server endpoints it accepted whose connection request hasn't been passed to the user yet.

Why?


A connection accepted by the TCP sockcm listener gets a server endpoint that keeps a pointer to the listener (ep->listener) until the client's private data arrives. Only then does it invoke the listener's conn_request_cb. uct_listener_destroy() only closed the listening socket and left those endpoints in sockcm->ep_list with their async handlers registered. When the client's data arrived later, the callback was invoked through the freed listener: a heap-use-after-free, usually a segfault in uct_tcp_sockcm_ep_server_invoke_conn_req_cb(), ucp_cm_server_conn_request_cb() or uct_listener_reject().

Applications hit this when they destroy a listener (ucp_listener_destroy()) while clients are still connecting.

How?


UCS_CLASS_CLEANUP_FUNC(uct_tcp_listener_t) now walks sockcm->ep_list under the async lock and closes the endpoints whose listener is the one being destroyed. It uses uct_tcp_sockcm_close_ep(), the same helper the CM cleanup already uses. Endpoints whose connection request was already passed to the user are removed from ep_list before the callback is invoked, so they're not affected. The client sees its connection closed.

The new test test_uct_sockaddr_tcp.destroy_listener_with_pending_conn_request connects a plain TCP socket to the listener and waits until the listener has accepted it. It then destroys the listener and checks three things:

  • the pending server endpoint was closed;

  • the client's connection is closed;

  • the connection request callback wasn't invoked after the client sent its private data.
  • Without the fix, the test fails at the first check.

    Diff: 222 lines (+166 / -56) across 2 files Reviewer: tvegas1 Review duration: 4169m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 222 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.323
    Real PR Conversation Timeline
    1 comments
    "Review active on #12465"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.8% (MEDIUM) · Higher = larger blast radius
    36.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.6% · Safe to merge
    19.6%
    Repository