Skip to content

Commit b0329c2

Browse files
authored
Backport coredump buffer ownership fixes to CUDA 12
Carry forward #2399: retain borrowed setter bytes and release getter-owned storage. Keep this runtime maintenance separate from the build integration. Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
1 parent 35e14d0 commit b0329c2

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎cuda_bindings_12/cuda/bindings/_lib/utils.pxd‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ cdef class _HelperCUcoredumpSettings:
152152
cdef cydriver.CUcoredumpSettings_enum _attrib
153153
cdef bint _is_getter
154154
cdef size_t _size
155+
cdef object _references # keeps caller bytes alive so _charstar stays valid
155156

156157
# Return values
157158
cdef cpp_bool _bool

‎cuda_bindings_12/cuda/bindings/_lib/utils.pxi‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ cdef class _HelperCUcoredumpSettings:
734734
self._cptr = <void*><void_ptr>self._charstar
735735
self._size = 1024
736736
else:
737+
# Keep a reference so the borrowed _charstar buffer stays alive.
738+
self._references = init_value
737739
self._charstar = init_value
738740
self._cptr = <void*><void_ptr>self._charstar
739741
self._size = len(init_value)
@@ -756,7 +758,9 @@ cdef class _HelperCUcoredumpSettings:
756758
raise TypeError('Unsupported attribute: {}'.format(attr.name))
757759

758760
def __dealloc__(self):
759-
pass
761+
# Only the getter owns heap storage; the setter borrows caller bytes.
762+
if self._is_getter:
763+
free(self._charstar)
760764

761765
@property
762766
def cptr(self):

0 commit comments

Comments
 (0)