pyverbs: Remove MREx.close() override to fix deallocation crash MREx.close() called the base close() and then reset its own cdef object member via 'self.dmah = None'. That assignment is both redundant and unsafe during deallocation. Cython's generated subclass deallocator clears the subclass cdef object members (dmah) before chaining to the base deallocator that runs the inherited MR.__dealloc__ -> self.close(). So when close() runs at deallocation time, dmah is already NULL and 'self.dmah = None' does an unguarded DECREF on NULL, segfaulting. This only stayed hidden while every MREx was closed explicitly first (which sets self.mr = NULL and makes the deallocation-time close() skip its body); an MREx reclaimed by the garbage collector crashes. Releasing dmah here is unnecessary: tp_dealloc already drops the reference, and MR.close() performs the ibv_dereg_mr(). Drop the override and inherit MR.close(), matching the other MR subclasses (e.g. DMMR) that do not reset their extra members in close(). Signed-off-by: Jiri Pirko <jiri@nvidia.com>
diff --git a/pyverbs/mr.pyx b/pyverbs/mr.pyx index 727c7ab..1921f70 100644 --- a/pyverbs/mr.pyx +++ b/pyverbs/mr.pyx
@@ -717,11 +717,6 @@ print_format.format('buf', <uintptr_t>self.buf) + \ print_format.format('handle', self.handle) - cpdef close(self): - """Close MREx and release its association with DMAHandle.""" - if self.mr != NULL: - super(MREx, self).close() - self.dmah = None cdef class Buf(PyverbsCM): """