Deregistration of memory regions causes segmentation error
The ibv_dereg_mr
function causes a segmentation fault in memory_ib_free
. This is probably caused, by memory_ib_mr
which returns the wrong pointer to the memory region.
Fix this problem and start using memory_ib_mr
in other places where we are doing pointer wizardry right now as well.
struct ibv_mr * memory_ib_mr(void *ptr)
{
struct ibv_mr *mr = (struct ibv_mr *) ptr;
return (mr - 1);
}
int memory_ib_free(struct memtype *m, void *ptr, size_t len)
{
struct memory_ib *mi = (struct memory_ib *) m->_vd;
struct ibv_mr *mr = memory_ib_mr(ptr);
ibv_dereg_mr(mr);
ptr -= sizeof(struct ibv_mr *);
len += sizeof(struct ibv_mr *);
memory_free(mi->parent, ptr, len);
return 0;
}