Skip to content

Commit 2484071

Browse files
Prevent subcomms from being freed before user's comm
Signed-off-by: Matthew Whitlock <[email protected]>
1 parent e2a2583 commit 2484071

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

ompi/mca/coll/han/coll_han_subcomms.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@
4646
(COMM)->c_coll->coll_##COLL##_module = (FALLBACKS).COLL.module; \
4747
} while (0)
4848

49+
#define HAN_SUBCOM_EXTRA_RETAIN(COMM) \
50+
do \
51+
{ \
52+
if(!OMPI_COMM_IS_EXTRA_RETAIN(COMM)){ \
53+
OMPI_COMM_SET_EXTRA_RETAIN(COMM); \
54+
OBJ_RETAIN(COMM); \
55+
} \
56+
} while (0)
57+
4958
/*
5059
* Routine that creates the local hierarchical sub-communicators
5160
* Called each time a collective is called.
@@ -206,6 +215,11 @@ int mca_coll_han_comm_create_new(struct ompi_communicator_t *comm,
206215
HAN_SUBCOM_RESTORE_COLLECTIVE(fallbacks, comm, han_module, scatterv);
207216

208217
OBJ_DESTRUCT(&comm_info);
218+
219+
/* Ensure these communicators aren't released before the parent comm */
220+
HAN_SUBCOM_EXTRA_RETAIN(*low_comm);
221+
HAN_SUBCOM_EXTRA_RETAIN(*up_comm);
222+
209223
return OMPI_SUCCESS;
210224

211225
return_with_error:
@@ -376,6 +390,12 @@ int mca_coll_han_comm_create(struct ompi_communicator_t *comm,
376390
han_module->cached_up_comms = up_comms;
377391
han_module->cached_vranks = vranks;
378392

393+
/* Ensure these communicators aren't released before the parent comm */
394+
HAN_SUBCOM_EXTRA_RETAIN(low_comms[0]);
395+
HAN_SUBCOM_EXTRA_RETAIN(low_comms[1]);
396+
HAN_SUBCOM_EXTRA_RETAIN( up_comms[0]);
397+
HAN_SUBCOM_EXTRA_RETAIN( up_comms[1]);
398+
379399
/* Reset the saved collectives to point back to HAN */
380400
HAN_SUBCOM_RESTORE_COLLECTIVE(fallbacks, comm, han_module, alltoall);
381401
HAN_SUBCOM_RESTORE_COLLECTIVE(fallbacks, comm, han_module, alltoallv);

0 commit comments

Comments
 (0)