Skip to content

Commit b8dbc41

Browse files
committed
rcache/grdma: fix crash when part of a registration is unmapped
This commit fixes an issue when a registration is created for a large region and then invalidated while part of it is in use. References open-mpi#4509 Signed-off-by: Nathan Hjelm <[email protected]> (cherry picked from commit 39d5988) Signed-off-by: Nathan Hjelm <[email protected]>
1 parent eb139ac commit b8dbc41

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

opal/mca/rcache/grdma/rcache_grdma_module.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,11 @@ static int mca_rcache_grdma_deregister (mca_rcache_base_module_t *rcache,
416416
return OPAL_SUCCESS;
417417
}
418418

419-
rc = dereg_mem (reg);
419+
if (!(reg->flags & MCA_RCACHE_FLAGS_INVALID)) {
420+
/* only call dereg mem if this registration is not in the GC lifo */
421+
rc = dereg_mem (reg);
422+
}
423+
420424
opal_mutex_unlock (&rcache_grdma->cache->vma_module->vma_lock);
421425

422426
return rc;
@@ -451,7 +455,7 @@ static int gc_add (mca_rcache_base_registration_t *grdma_reg, void *ctx)
451455
/* This may be called from free() so avoid recursively calling into free by just
452456
* shifting this registration into the garbage collection list. The cleanup will
453457
* be done on the next registration attempt. */
454-
if (registration_is_cacheable (grdma_reg)) {
458+
if (registration_is_cacheable (grdma_reg) && !grdma_reg->ref_count) {
455459
opal_list_remove_item (&rcache_grdma->cache->lru_list, (opal_list_item_t *) grdma_reg);
456460
}
457461

0 commit comments

Comments
 (0)