← Back to Pull requests

[cudax] Do not read managed memory from the host after starting work in the stream adaptor #12134

Open
SUKUNA-AI opened this pull request with 7 lines diff across 1 files
View on GitHub
SUKUNA-AI SUKUNA-AI commented on Oct 21, 2026 17:27 UTC
Author

Description

Fixes the stdexec_stream segfault from #8902. The vector_add failure there is a separate problem; see below.

On devices where cudaDevAttrConcurrentManagedAccess is 0 (Windows, and Linux under WSL2), the host must not touch managed memory while a kernel is running. __stream::__opstate_t::__host_start in stream/adaptor.cuh:

1. starts the child operation, which launches the predecessor kernels;
2. then calls ::cuda::launch(__stream_, ...), which reads the __stream_ member (launch.h:611 builds __ensure_current_context from the submitter).

When this opstate lives in the __managed_box that the stream sync_wait allocates (sync_wait.cuh:101), step 2 is a host read of managed memory while a kernel is in flight. The process faults: SIGSEGV on WSL2, 0xC0000006 on Windows. In gdb, every crashing [stream] test case stops at adaptor.cuh:281, reached from the start() call on line 275.

This change copies the stream into a local before starting the child operation.

schedule_from.cuh also reads __stream_ after start(), but its opstate is documented as being stored in host memory, so I left it unchanged.

Testing

RTX 5070 Ti (sm_120), driver 617.42, concurrentManagedAccess == 0:

| | before | after |
|---|---|---|
| cudax.test.execution (WSL2, nvcc 13.4.59, gcc 16.2) | 7 of 9 [stream] test cases crash | 197/197 test cases pass |
| cudax/examples/stdexec_stream.cu (WSL2) | SIGSEGV | passes |
| cudax/examples/stdexec_stream.cu (native Windows, nvcc 13.4.92, MSVC 19.51, C++20) | 0xC0000006 | passes |

Before the change, everything passes with CUDA_LAUNCH_BLOCKING=1, which matches the diagnosis.

The vector_add failure from #8902 is a different problem. With this change it still fails on native Windows (MSVC), and it passes on WSL2 with gcc.

Checklist


  • New or existing tests cover these changes. (Existing [stream] test cases in cudax.test.execution. They only fail on devices without concurrent managed access, so Linux CI does not see this.)

  • The documentation is up to date with these changes. (No user-visible change.)
  • Diff: 7 lines (+6 / -1) across 1 files Reviewer: andralex Review duration: 12752m
    All Vouch review confidence checks passed
    Residual risk 0.04 = Change Risk (0.15) × (1 − Review Confidence (0.72)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.15 · 7 lines diff across 1 files
    0.15
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.58 · 2 substantive comment(s)
    0.58
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    71%
    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
    Diff Size diff_size
    0.124
    Real PR Conversation Timeline
    4 items
    copy-pr-bot[bot] copy-pr-bot[bot] commented on Oct 21, 2026 17:27 UTC
    Bot

    This pull request requires additional validation before any workflows can run on NVIDIA's runners.

    Pull request vetters can view their responsibilities here.

    Contributors can view more details about this message here.

    coderabbitai[bot] coderabbitai[bot] commented on Oct 21, 2026 17:32 UTC
    Bot

    <!-- coderabbit-ai-generated:v1 -->

    <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
    <!-- review_stack_entry_start -->

    <a href="https://app.coderabbit.ai/change-stack/NVIDIA/cccl/pull/12134?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a>

    <!-- review_stack_entry_end -->
    <!-- This is an auto-generated comment: skip review by coderabbit.ai -->

    [!IMPORTANT]

    ## Review skipped

    > Review was skipped as selected files did not have any reviewable changes.

    >

    >

    > <details>

    <summary><strong>⚙️ Run configuration</strong></summary>

    <dl>

    <dd>

    > - Source mode: Auto

    - Repository: [NVIDIA/cccl](<https://github.com/NVIDIA/cccl>)

    - Branch: [main](<https://github.com/NVIDIA/cccl/tree/main>)

    - File: [.coderabbit.yaml](<https://github.com/NVIDIA/cccl/blob/b94ca2aa922d45b9b53e3ce4eff9a9a5e252c7f1/.coderabbit.yaml>)

    - Commit: [b94ca2a](<https://github.com/NVIDIA/cccl/commit/b94ca2aa922d45b9b53e3ce4eff9a9a5e252c7f1>)

    - Layers: Repository YAML

    - Review profile: CHILL

    - Plan: Enterprise

    - Run ID: 2aac8f12-bd8b-44da-9fc1-3d93726e636f

    > </dd>

    </dl>

    </details>

    > <details>

    <summary><strong>📥 Commits</strong></summary>

    <dl>

    <dd>

    > Reviewing files that changed from the base of the PR and between e71d8b43d912b668e48b9dd6d34a76f67b9d9e69 and c13fdef8eb6a82e09792ff06c043d0d761896527.

    > </dd>

    </dl>

    </details>

    > You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

    > Use the checkbox below for a quick retry:

    - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review

    <!-- end of auto-generated comment: skip review by coderabbit.ai -->

    <!-- recent_review_start -->

    No actionable comments were generated in the recent review. 🎉

    <details>
    <summary><strong>ℹ️ Recent review info</strong></summary>
    <dl>
    <dd>

    <details>
    <summary><strong>⚙️ Run configuration</strong></summary>
    <dl>
    <dd>

  • Configuration used: Repository: NVIDIA/cccl/.coderabbit.yaml

  • Review profile: CHILL

  • Plan: Enterprise

  • Run ID: 6c3df3bb-9d80-40a5-9b1d-1d62cd443c8c
  • </dd>
    </dl>
    </details>

    <details>
    <summary><strong>📥 Commits</strong></summary>
    <dl>
    <dd>

    Reviewing files that changed from the base of the PR and between 6ad0be74a142127e0cf8a90f54210325b26538ee and 5d8496d776d4c2e4cb3c81643ca5481739e1d98d.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>📒 Files selected for processing: 1</strong></summary>
    <dl>
    <dd>

  • cudax/include/cuda/experimental/__execution/stream/adaptor.cuh
  • </dd>
    </dl>
    </details>

    Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

    </dd>
    </dl>
    </details>

    <!-- recent_review_end -->
    <!-- walkthrough_start -->

    <details>
    <summary><strong>📝 Summary</strong></summary>
    <dl>
    <dd>

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

  • Bug Fixes

  • - Improved reliability when launching completion operations on systems without concurrent managed-memory access, including Windows and WSL.
    - Prevented potential invalid access to stream state after device work has started.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->
    The host start path now captures __stream_ before starting the child operation. It uses the local stream reference for the completion-kernel launch.

    Changes: Stream adaptor start path

    |Layer / File(s)|Summary|
    |:---|:---|
    |Capture stream and launch completion kernel <br> cudax/include/cuda/experimental/__execution/stream/adaptor.cuh|__host_start copies __stream_ to a local variable before starting the child operation. The completion-kernel launch then uses that local stream.|

    Possibly related issues

  • NVIDIA/cccl#8902: The issue reports a Windows segmentation fault in a stream operation chain. This change addresses the managed-memory stream read described for that behavior.
  • </dd>
    </dl>
    </details>

    <!-- walkthrough_end -->
    <!-- change_assessment_start -->
    Priority: ➖ Normal

    <!-- change_assessment_commit:"5d8496d776d4c2e4cb3c81643ca5481739e1d98d" -->
    Change: Bug fix · Severity of issue fixed: Medium
    <!-- change_assessment_end -->
    <details>
    <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>5d849</code></summary>
    <dl>
    <dd>

    <!-- final_review_risk_start -->
    <!-- final_review_risk_label
    Merge Risk: ⚪ Minimal · up to 5d849
    -->
    <!-- final_review_risk_coverage:{"sourceCommitId":"5d8496d776d4c2e4cb3c81643ca5481739e1d98d","coveredCommitId":"5d8496d776d4c2e4cb3c81643ca5481739e1d98d","kind":"reviewed"} -->

    The targeted stream capture fix is ready to merge; no actionable risks remain.
    <!-- final_review_risk_end -->

    </dd>
    </dl>
    </details>
    <!-- autopilot:start -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- autopilot:end -->
    <!-- tips_start -->

    <sub>Comment @coderabbitai help to get the list of available commands.</sub>

    <!-- tips_end -->

    andralex andralex approved these changes on Oct 21, 2026 23:33 UTC
    Approved Reviewer

    lgtm

    Reviewers
    Assignees
    SUKUNA-AI SUKUNA-AI
    Labels
    risk: low confidence: 71.9% 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: 15.4% (LOW) · Higher = larger blast radius
    15.4%
    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: 71.9% · Lower = rushed or shallow review
    71.9%
    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: 4.3% · Safe to merge
    4.3%
    Repository