Skip to content

fix(cuda-core): require 'static on simt launch_host_function - #1388

Open
Rachit2323 wants to merge 1 commit into
NVIDIA:mainfrom
Rachit2323:fix/cuda-core-host-callback-static
Open

Rachit2323 wants to merge 1 commit into
NVIDIA:mainfrom
Rachit2323:fix/cuda-core-host-callback-static

Conversation

@Rachit2323

Copy link
Copy Markdown

Fixes #1387

Summary

launch_host_function in cuda-core/src/simt/stream.rs runs the callback later on a driver thread, but it didn't require 'static. So a closure could borrow a local that's already dropped by the time it runs. The version in runtime.rs already has the bound.

Changes

  • Added 'static to launch_host_function and callback_wrapper
  • Added a compile_fail doc test for a borrowing closure

All existing callers already pass move closures, so nothing else needed changing.

Testing

  • just -f cuda-oxide/Justfile check passes (the local mirror of CI: fmt, clippy, tests, guards, docs)
  • cargo oxide run <example> passes, or cuda-oxide/scripts/smoketest.sh -o '^<example>$'
  • New example added (if applicable)

On macOS (CUDA headers only, no GPU): cargo check, cargo clippy and cargo fmt --check pass for cuda-core and cuda-async. The new doc test passes, and the same snippet compiles on current main, so the test is checking the right thing. Haven't run it on a GPU.

Checklist

  • All commits signed off (git commit -s)
  • SPDX headers on new source files (no new files)

The callback runs later on a driver thread, so it can't borrow locals.

Fixes NVIDIA#1387

Signed-off-by: Rachit2323 <atreyrachit23@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: simt launch_host_function lets a callback borrow local data

1 participant