Skip to content

[libcu++] Fix host_launch callback data leak on registration failure - #12087

Merged
pciolkosz merged 4 commits into
NVIDIA:mainfrom
pciolkosz:fix-host-launch-callback-leak
Oct 29, 2026
Merged

pciolkosz merged 4 commits into
NVIDIA:mainfrom
pciolkosz:fix-host-launch-callback-leak

Conversation

@pciolkosz

Copy link
Copy Markdown
Contributor

If __streamAddCallback throws we would leak __callback_data_ptr, this PR fixes that with unique_ptr

@pciolkosz
pciolkosz requested a review from a team as a code owner October 20, 2026 01:29
@pciolkosz
pciolkosz requested a review from Jacobfaib October 20, 2026 01:29
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Oct 20, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Oct 20, 2026
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

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

Run configuration
  • Source mode: Auto
  • Repository: NVIDIA/cccl
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 06b483c
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 1ff4ea5d-c438-4198-920f-6edc6973a48d
Commits

Reviewing files that changed from the base of the PR and between 3a1d933 and e4e12b4.

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:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: NVIDIA/cccl
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 2ac6c18
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 9c8cb2b1-319e-4bae-9fb4-a624a767f752
Commits

Reviewing files that changed from the base of the PR and between 15298a0 and 3a1d933.

Files selected for processing: 1
  • libcudacxx/include/cuda/__launch/host_launch.h
Files skipped from review as they are similar to previous changes: 1
  • libcudacxx/include/cuda/__launch/host_launch.h

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

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of host-side stream callback handling. Callback setup data is retained until registration completes and cleaned up if registration exits early, helping prevent resource leaks.
    • Added explicit cleanup for callback data on the host, making resource handling more consistent across registration outcomes.

host_launch now owns callback data with unique_ptr during stream callback registration and releases ownership after registration returns. The change also adds an explicit host destructor for __stream_callback_data and updates the copyright year.

Changes: Host callback data ownership

Layer / File(s) Summary
Callback data lifecycle
libcudacxx/include/cuda/__launch/host_launch.h
The code adds the unique_ptr header and an execution-check-disabled host destructor for __stream_callback_data. host_launch retains callback data with unique_ptr during registration, then releases it after registration returns. The copyright year changes to 2026.

Suggested reviewers: davebayer

Priority: Low

Change: Bug fix

Merge Risk: Minimal · previous review 3a1d9

No actionable issue remains from this review; the change is mergeable after normal checks.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cccl/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: acfe00ef-23f7-4337-b1fe-060f651532ee
📥 Commits

Reviewing files that changed from the base of the PR and between 2ac6c18 and 15298a0.

📒 Files selected for processing: 1
  • libcudacxx/include/cuda/__launch/host_launch.h

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

@github-actions

This comment has been minimized.

Comment on lines 60 to 65
auto* __casted_data_ptr = static_cast<_CallbackData*>(__data_ptr);
if (__status == ::CUDA_SUCCESS)
{
(void) ::cuda::std::apply(__casted_data_ptr->__callable_, ::cuda::std::move(__casted_data_ptr->__args_));
}
delete __casted_data_ptr;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should wrap this in a unique_ptr as well. The user callable may throw and we leak the _CallbackData* all the same

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 13m: Pass: 100%/228 | Total: 5d 04h | Max: 2h 12m | Hits: 66%/1087271

See results here.

@pciolkosz
pciolkosz merged commit 4031d2a into NVIDIA:main Oct 29, 2026
248 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants