Repository navigation
cuda-macros: keep generic kernel specializations alive with black_box, not a null-pointer volatile pair - #1226
Merged
Conversation
… a null-pointer volatile pair Every generic #[kernel] expands a ptx_name() helper whose only job is to make rustc collect the concrete kernel instantiation for the device backend. It did that by writing the reified fn pointer into a local that started as core::ptr::null() through write_volatile and reading it back. CodeQL's rust/access-invalid-pointer query follows that flow (null -> local -> volatile access) and reports it at every #[cuda_module] and #[kernel] site: all 13 open alerts on main, and the same 13 re-reported as new on any large PR. core::hint::black_box on the reify cast keeps the cast from being optimized away just as well (the #[cuda_module] loader already relies on black_box for the same purpose) and touches no pointer, so the query has nothing to follow. The two internal idents the old body needed go away with it; the hygiene probes that name them stay valid, they just probe a name the macro no longer introduces. Validated on an RTX 5090: cuda-macros and cuda-host suites, and the smoketest over the eleven alerted examples plus vecadd, async_vecadd, cluster and cuda_module_in_lib (15/15 pass, generic kernels included). Signed-off-by: Nihal Pasham <[email protected]>
8 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every generic
#[kernel]expands aptx_name()helper whose only job is to make rustc collect the concrete kernel instantiation for the device backend. It did that with a null pointer and a volatile write/read:CodeQL's
rust/access-invalid-pointerfollowsnull -> local -> volatile accessand reports it at every#[cuda_module]/#[kernel]site. That is all 13 open alerts on main, and the same 13 come back as "new" on any large PR (#1102).black_boxkeeps the reify cast alive just as well (the#[cuda_module]loader already uses it for the same reason) and touches no pointer. The two internal idents go away with it; the hygiene probes that name them still compile, they just probe a name the macro no longer introduces.Validated on an RTX 5090:
The 13 alerts close on the next main scan; the CodeQL check on this PR is the proof.