Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions cuda_core/cuda/core/experimental/_memory.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ cdef class Buffer(_cyBuffer, MemoryResourceAttributes):
s = <cyStream>stream
self._mr._deallocate(self._ptr, self._size, s)
self._ptr = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

This was something I had mentioned elsewhere, that we shouldn't be accessing object properties in a __dealloc__ code path.

Why is _ptr still being touched here?

From the Cython docs on __dealloc__:

In particular, don’t call any other methods of the object or do anything which might cause the object to be resurrected. It’s best if you stick to just deallocating C data.

Why not just do the minimum C-API invocation required in __dealloc__ and duplicate whatever you need to from close?

Then we're not going against the documented behavior and causing a crashing knowing that we could have avoided it all along.

Copy link
Member Author

Choose a reason for hiding this comment

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

self._ptr is a cdef attribute. I think it might be a confusion with self._ptr_obj?

Regardless, I don't believe this PR is needed. I think #1104 and #1105 together should fix everything for us.

self._mr = None
self._ptr_obj = None
self._alloc_stream = None

@property
def handle(self) -> DevicePointerT:
Expand Down Expand Up @@ -763,12 +760,9 @@ cdef class DeviceMemoryResource(MemoryResource):
self.unregister()
self._dev_id = cydriver.CU_DEVICE_INVALID
self._mempool_handle = NULL
self._attributes = None
self._ipc_handle_type = cydriver.CUmemAllocationHandleType.CU_MEM_HANDLE_TYPE_MAX
self._mempool_owned = False
self._is_mapped = False
self._uuid = None
self._alloc_handle = None

def __reduce__(self):
return DeviceMemoryResource.from_registry, (self.uuid,)
Expand Down
Loading