Skip to content

ROCM-26531 - Fix capture graph leak on execution-context stream detach#7773

Open
victzhan wants to merge 2 commits into
developfrom
ROCM-26531/victzhan
Open

ROCM-26531 - Fix capture graph leak on execution-context stream detach#7773
victzhan wants to merge 2 commits into
developfrom
ROCM-26531/victzhan

Conversation

@victzhan

@victzhan victzhan commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Motivation

Fix the ROCM-26531 LeakSanitizer regression where destroying an execution context that owns a stream with an active capture leaks the captured graph.

Technical Details

Free the captured graph in Stream::Detach() when the capture is invalidated, since the detached stream can no longer reach hipStreamEndCapture's cleanup. Only the origin frees it; forked streams just clear their aliased pointer to avoid a double free.

JIRA ID

ROCM-26531

Test Plan

Ran the two failing capture-detach tests and all other relative tests

Test Result

No regression

Submission Checklist

When an ExecutionCtx is destroyed while one of its streams has an active
stream capture, Stream::Detach() invalidated the capture but never freed
the captured hip::Graph. The graph could no longer be reclaimed because
hipStreamEndCapture_common early-returns hipErrorStreamDetached (via
CHECK_STREAM_DETACHED) before reaching its ReleaseCaptureGraph() cleanup,
and hipStreamDestroy's EndCapture() only nulls the pointer. The graph
(owned solely by pCaptureGraph_) was therefore orphaned, producing the
LeakSanitizer "Direct leak of 776 byte(s)" reported in ROCM-26531.

Free the captured graph at the detach point, gated on the origin stream
so it is deleted exactly once. Forked (parallel) capture streams only
alias the origin's graph, so clear their pointer first to avoid a double
free.

Fixes: ROCM-26531
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant