Skip to content

Commit 7ef4f20

Browse files
committed
ROMIO: store temporary ompi_info_t on stack
No need to allocate it on the heap using OBJ_NEW. Also fixes a mismatch between OBJ_NEW and ompi_info_free that potentially leads to inconsistencies in ref-counting the ompi instance. Signed-off-by: Joseph Schuchart <schuchart@icl.utk.edu>
1 parent 50d8012 commit 7ef4f20

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

ompi/mca/io/romio341/src/io_romio341_component.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -243,17 +243,16 @@ static int delete_select(const char *filename, struct opal_info_t *info,
243243
// An opal_info_t isn't a full ompi_info_t. so if we're using an MPI call
244244
// below with an MPI_Info, we need to create an equivalent MPI_Info. This
245245
// isn't ideal but it only happens a few places.
246-
ompi_info_t *ompi_info;
247-
ompi_info = OBJ_NEW(ompi_info_t);
248-
if (!ompi_info) { return(MPI_ERR_NO_MEM); }
249-
opal_info_t *opal_info = &(ompi_info->super);
246+
ompi_info_t ompi_info;
247+
OBJ_CONSTRUCT(&ompi_info, ompi_info_t);
248+
opal_info_t *opal_info = &(ompi_info.super);
250249
opal_info_dup (info, &opal_info);
251250

252251
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
253-
ret = ROMIO_PREFIX(MPI_File_delete)(filename, ompi_info);
252+
ret = ROMIO_PREFIX(MPI_File_delete)(filename, &ompi_info);
254253
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
255254

256-
ompi_info_free(&ompi_info);
255+
OBJ_DESTRUCT(&ompi_info);
257256
return ret;
258257
}
259258

ompi/mca/io/romio341/src/io_romio341_file_open.c

+10-12
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,18 @@ mca_io_romio341_file_open (ompi_communicator_t *comm,
4141
// An opal_info_t isn't a full ompi_info_t. so if we're using an MPI call
4242
// below with an MPI_Info, we need to create an equivalent MPI_Info. This
4343
// isn't ideal but it only happens a few places.
44-
ompi_info_t *ompi_info;
45-
ompi_info = OBJ_NEW(ompi_info_t);
46-
if (!ompi_info) { return(MPI_ERR_NO_MEM); }
47-
opal_info_t *opal_info = &(ompi_info->super);
44+
ompi_info_t ompi_info;
45+
OBJ_CONSTRUCT(&ompi_info, ompi_info_t);
46+
opal_info_t *opal_info = &(ompi_info.super);
4847
opal_info_dup (info, &opal_info);
4948

5049
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
5150
// OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
52-
ret = ROMIO_PREFIX(MPI_File_open)(comm, filename, amode, ompi_info,
51+
ret = ROMIO_PREFIX(MPI_File_open)(comm, filename, amode, &ompi_info,
5352
&data->romio_fh);
5453
// OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
5554

56-
ompi_info_free(&ompi_info);
55+
OBJ_DESTRUCT(&ompi_info);
5756
return ret;
5857
}
5958

@@ -206,20 +205,19 @@ mca_io_romio341_file_set_view (ompi_file_t *fh,
206205
// An opal_info_t isn't a full ompi_info_t. so if we're using an MPI call
207206
// below with an MPI_Info, we need to create an equivalent MPI_Info. This
208207
// isn't ideal but it only happens a few places.
209-
ompi_info_t *ompi_info;
210-
ompi_info = OBJ_NEW(ompi_info_t);
211-
if (!ompi_info) { return(MPI_ERR_NO_MEM); }
212-
opal_info_t *opal_info = &(ompi_info->super);
208+
ompi_info_t ompi_info;
209+
OBJ_CONSTRUCT(&ompi_info, ompi_info_t);
210+
opal_info_t *opal_info = &(ompi_info.super);
213211
opal_info_dup (info, &opal_info);
214212

215213
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
216214
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
217215
ret =
218216
ROMIO_PREFIX(MPI_File_set_view) (data->romio_fh, disp, etype, filetype,
219-
datarep, ompi_info);
217+
datarep, &ompi_info);
220218
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
221219

222-
ompi_info_free(&ompi_info);
220+
OBJ_DESTRUCT(&ompi_info);
223221
return ret;
224222
}
225223

0 commit comments

Comments
 (0)