Skip to content

Commit 0a09f8b

Browse files
committed
coll/hcoll: Protect module destruct when not fully initialized
* If hcoll is given a negative priority, but not enabled=0 then the module is constructed, but then destructed before calling it's query(). So the previous pointers are not initialized. If we try to OBJ_RELEASE them in a debug build an assert will fire. This commit adds some protection against that and initializes the _module pointers to NULL.
1 parent 59f304b commit 0a09f8b

File tree

1 file changed

+48
-19
lines changed

1 file changed

+48
-19
lines changed

ompi/mca/coll/hcoll/coll_hcoll_module.c

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
Copyright (c) 2011 Mellanox Technologies. All rights reserved.
3+
Copyright (c) 2016 IBM Corporation. All rights reserved.
34
$COPYRIGHT$
45
56
Additional copyrights may follow
@@ -50,6 +51,32 @@ static void mca_coll_hcoll_module_clear(mca_coll_hcoll_module_t *hcoll_module)
5051
hcoll_module->previous_iallgatherv = NULL;
5152
hcoll_module->previous_igatherv = NULL;
5253
hcoll_module->previous_ireduce = NULL;
54+
hcoll_module->previous_ialltoall = NULL;
55+
hcoll_module->previous_ialltoallv = NULL;
56+
57+
hcoll_module->previous_barrier_module = NULL;
58+
hcoll_module->previous_bcast_module = NULL;
59+
hcoll_module->previous_allreduce_module = NULL;
60+
hcoll_module->previous_reduce_module = NULL;
61+
hcoll_module->previous_allgather_module = NULL;
62+
hcoll_module->previous_allgatherv_module = NULL;
63+
hcoll_module->previous_gather_module = NULL;
64+
hcoll_module->previous_gatherv_module = NULL;
65+
hcoll_module->previous_alltoall_module = NULL;
66+
hcoll_module->previous_alltoallv_module = NULL;
67+
hcoll_module->previous_alltoallw_module = NULL;
68+
hcoll_module->previous_reduce_scatter_module = NULL;
69+
hcoll_module->previous_ibarrier_module = NULL;
70+
hcoll_module->previous_ibcast_module = NULL;
71+
hcoll_module->previous_iallreduce_module = NULL;
72+
hcoll_module->previous_ireduce_module = NULL;
73+
hcoll_module->previous_iallgather_module = NULL;
74+
hcoll_module->previous_iallgatherv_module = NULL;
75+
hcoll_module->previous_igatherv_module = NULL;
76+
hcoll_module->previous_ialltoall_module = NULL;
77+
hcoll_module->previous_ialltoallv_module = NULL;
78+
79+
5380
}
5481

5582
static void mca_coll_hcoll_module_construct(mca_coll_hcoll_module_t *hcoll_module)
@@ -63,6 +90,8 @@ void mca_coll_hcoll_mem_release_cb(void *buf, size_t length,
6390
hcoll_mem_unmap(buf, length, cbdata, from_alloc);
6491
}
6592

93+
#define OBJ_RELEASE_IF_NOT_NULL( obj ) if( NULL != (obj) ) OBJ_RELEASE( obj );
94+
6695
static void mca_coll_hcoll_module_destruct(mca_coll_hcoll_module_t *hcoll_module)
6796
{
6897
int context_destroyed;
@@ -79,25 +108,25 @@ static void mca_coll_hcoll_module_destruct(mca_coll_hcoll_module_t *hcoll_module
79108
destroy hcoll context*/
80109

81110
if (hcoll_module->hcoll_context != NULL){
82-
OBJ_RELEASE(hcoll_module->previous_barrier_module);
83-
OBJ_RELEASE(hcoll_module->previous_bcast_module);
84-
OBJ_RELEASE(hcoll_module->previous_allreduce_module);
85-
OBJ_RELEASE(hcoll_module->previous_allgather_module);
86-
OBJ_RELEASE(hcoll_module->previous_allgatherv_module);
87-
OBJ_RELEASE(hcoll_module->previous_gatherv_module);
88-
OBJ_RELEASE(hcoll_module->previous_alltoall_module);
89-
OBJ_RELEASE(hcoll_module->previous_alltoallv_module);
90-
OBJ_RELEASE(hcoll_module->previous_reduce_module);
91-
92-
OBJ_RELEASE(hcoll_module->previous_ibarrier_module);
93-
OBJ_RELEASE(hcoll_module->previous_ibcast_module);
94-
OBJ_RELEASE(hcoll_module->previous_iallreduce_module);
95-
OBJ_RELEASE(hcoll_module->previous_iallgather_module);
96-
OBJ_RELEASE(hcoll_module->previous_iallgatherv_module);
97-
OBJ_RELEASE(hcoll_module->previous_igatherv_module);
98-
OBJ_RELEASE(hcoll_module->previous_ialltoall_module);
99-
OBJ_RELEASE(hcoll_module->previous_ialltoallv_module);
100-
OBJ_RELEASE(hcoll_module->previous_ireduce_module);
111+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_barrier_module);
112+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_bcast_module);
113+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_allreduce_module);
114+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_allgather_module);
115+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_allgatherv_module);
116+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_gatherv_module);
117+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_alltoall_module);
118+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_alltoallv_module);
119+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_reduce_module);
120+
121+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_ibarrier_module);
122+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_ibcast_module);
123+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_iallreduce_module);
124+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_iallgather_module);
125+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_iallgatherv_module);
126+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_igatherv_module);
127+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_ialltoall_module);
128+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_ialltoallv_module);
129+
OBJ_RELEASE_IF_NOT_NULL(hcoll_module->previous_ireduce_module);
101130

102131
/*
103132
OBJ_RELEASE(hcoll_module->previous_allgatherv_module);

0 commit comments

Comments
 (0)