Skip to content

BUG: Fix use-after-free in _HelperInputVoidPtr properties#1629

Merged
mdboom merged 4 commits intoNVIDIA:mainfrom
mdboom:fix-dangling-ref-helper-input-void-ptr
Feb 17, 2026
Merged

BUG: Fix use-after-free in _HelperInputVoidPtr properties#1629
mdboom merged 4 commits intoNVIDIA:mainfrom
mdboom:fix-dangling-ref-helper-input-void-ptr

Conversation

@mdboom
Copy link
Contributor

@mdboom mdboom commented Feb 17, 2026

While working on #1616, I discovered a use-after-free bug in how void * properties are handled by one of our generators (affecting driver/runtime/nvrtc).

If a void * property value is set to a Python buffer, the reference to that buffer is not held, so if the buffer is independently free'd elsewhere, the pointer becomes dangling. The new unit test here hopefully illustrates the problem.

There is a related bug in _HelperInputVoidPtrPtr that references to each of the individual buffers are not held so could also get freed early. That bug is less critical since we don't currently use them as properties, only as variables within function calls, so it's actually hard to trigger that bug from the outside. But I thought we should fix it while we are here so it isn't a latent bug if we ever do add support for void ** properties.

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Feb 17, 2026

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@mdboom
Copy link
Contributor Author

mdboom commented Feb 17, 2026

/ok to test

@mdboom mdboom added bug Something isn't working P0 High priority - Must do! cuda.bindings Everything related to the cuda.bindings module labels Feb 17, 2026
@github-actions

This comment has been minimized.

@mdboom
Copy link
Contributor Author

mdboom commented Feb 17, 2026

/ok to test


cdef class _InputVoidPtrPtrHelper:
def __cinit__(self, lst):
self._references = lst
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth a comment if possible, so that humans and bots don't think this code is dead code.

@mdboom mdboom self-assigned this Feb 17, 2026
@rparolin rparolin added this to the cuda.bindings 13.1.2 & 12.9.6 milestone Feb 17, 2026
@mdboom mdboom enabled auto-merge (squash) February 17, 2026 20:39
@mdboom
Copy link
Contributor Author

mdboom commented Feb 17, 2026

/ok to test

@mdboom mdboom merged commit 0a00e4c into NVIDIA:main Feb 17, 2026
86 checks passed
@github-actions
Copy link

Doc Preview CI
Preview removed because the pull request was closed or merged.

@leofang leofang modified the milestones: cuda.bindings 13.1.2 & 12.9.6, cuda.bindings next Feb 17, 2026
@mdboom mdboom added the to-be-backported Trigger the bot to raise a backport PR upon merge label Feb 18, 2026
@github-actions
Copy link

Backport failed for 12.9.x, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 12.9.x
git worktree add -d .worktree/backport-1629-to-12.9.x origin/12.9.x
cd .worktree/backport-1629-to-12.9.x
git switch --create backport-1629-to-12.9.x
git cherry-pick -x 0a00e4cb02e2f98d8463aa241346e4e32f5270e4

mdboom added a commit to mdboom/cuda-python that referenced this pull request Feb 18, 2026
* BUG: Fix use-after-free in _HelperInputVoidPtr properties

* Revert cptr ref

* Apply suggestion from @mdboom

(cherry picked from commit 0a00e4c)
mdboom added a commit to mdboom/cuda-python that referenced this pull request Feb 18, 2026
* BUG: Fix use-after-free in _HelperInputVoidPtr properties

* Revert cptr ref

* Apply suggestion from @mdboom
mdboom added a commit that referenced this pull request Feb 19, 2026
* BUG: Fix use-after-free in _HelperInputVoidPtr properties (#1629)

* BUG: Fix use-after-free in _HelperInputVoidPtr properties

* Revert cptr ref

* Apply suggestion from @mdboom

* Add fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.bindings Everything related to the cuda.bindings module P0 High priority - Must do! to-be-backported Trigger the bot to raise a backport PR upon merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments