← Back to Pull requests

[STF] Long tail of cuda_safe_call in guards, deleters and destructors: release under notify, restore under abort #11774

Closed
unknown closed this pull request without merging on Oct 02, 2026 06:00 UTC
View on GitHub
unknown unknown commented on Sep 30, 2026 20:29 UTC
Author

Description

The remaining cuda_safe_call sites outside the files already covered by #11740, #11748, #11770, #11772 and #11773: twenty-two sites across eight headers, grouped by what the call does rather than where it lives.

Releases, ON_THROW(notify) around cuda_try. The resource leaks and is reported with its location; the frame cannot throw; nothing else is at stake.

  • shared_ptr deleters destroying a cudaGraphExec_t: algorithm.cuh (two), executable_graph_cache.cuh.

  • SCOPE(fail) releasing a graph that is still ours: stackable_ctx_impl.cuh (two).

  • SCOPE(fail) freeing a buffer after a failed initialization: stream/interfaces/hashtable_linearprobing.cuh, memory.cuh (two), and the two catch (...) fallbacks in memory.cuh's never-throw pool inserts.

  • Events: the stream_and_event destructor, the synchronization event in event_types.cuh, the timing events in stream_ctx.cuh, a SCOPE(fail) after event creation, and cudaHostUnregister in stream_ctx.cuh.
  • Restoring ambient state, ON_THROW(abort). Two cuCtxPopCurrent in event_types.cuh and cudaSetDevice(prev_device) in stream_ctx.cuh. These are not releases: if restoring the context or device fails, everything after runs against the wrong one and fails somewhere unrelated, which is the misattribution failure we least want. Reporting and stopping is the honest answer.

    Plain calls. One cudaEventRecord in a device-place lambda after its own fail guard becomes cuda_try; the context.cuh unit tests use the introspected cuda_safe_call<fn> for cleanup and cuda_try in a task body.

    A bug fixed on the way. The two cudaGraphExec_t deleters in algorithm.cuh neither freed the heap cell they were handed nor skipped a null handle, so every cached executable graph leaked eight bytes and a failed instantiation would have destroyed a null handle. They now do both, exactly as graph_ctx.cuh's deleters do.

    After this, the only cuda_safe_call uses left in the STF headers are the timing blocks that #11652 replaces and the sites in the four open batch PRs.

    Checklist


  • New or existing tests cover these changes.

  • The documentation is up to date with these changes.
  • 🤖 Generated with Claude Code

    Diff: 285 lines (+213 / -72) across 3 files Reviewer: caugonnet Review duration: 2010m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 285 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.338
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #11774"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 39.8% (MEDIUM) · Higher = larger blast radius
    39.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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 15.7% · Safe to merge
    15.7%
    Repository