Skip to content

Commit 2960963

Browse files
committed
mpi/c: Protect some IO functions not widely implemented
* Protects us from segv when ROMIO 314 is selected and one of the following operations is called: - MPI_File_iread_at_all - MPI_File_iwrite_at_all - MPI_File_iread_all - MPI_File_iwrite_all Signed-off-by: Joshua Hursey <[email protected]>
1 parent 2ffaf5e commit 2960963

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

ompi/mpi/c/file_iread_all.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Copyright (c) 2015 University of Houston. All rights reserved.
1414
* Copyright (c) 2015 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1617
* $COPYRIGHT$
1718
*
1819
* Additional copyrights may follow
@@ -71,8 +72,13 @@ int MPI_File_iread_all(MPI_File fh, void *buf, int count,
7172
/* Call the back-end io component function */
7273
switch (fh->f_io_version) {
7374
case MCA_IO_BASE_V_2_0_0:
74-
rc = fh->f_io_selected_module.v2_0_0.
75-
io_module_file_iread_all(fh, buf, count, datatype, request);
75+
if( OPAL_UNLIKELY(NULL == fh->f_io_selected_module.v2_0_0.io_module_file_iread_all) ) {
76+
rc = MPI_ERR_UNSUPPORTED_OPERATION;
77+
}
78+
else {
79+
rc = fh->f_io_selected_module.v2_0_0.
80+
io_module_file_iread_all(fh, buf, count, datatype, request);
81+
}
7682
break;
7783

7884
default:

ompi/mpi/c/file_iread_at_all.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Copyright (c) 2015 University of Houston. All rights reserved.
1414
* Copyright (c) 2015 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1617
* $COPYRIGHT$
1718
*
1819
* Additional copyrights may follow
@@ -71,9 +72,14 @@ int MPI_File_iread_at_all(MPI_File fh, MPI_Offset offset, void *buf,
7172
/* Call the back-end io component function */
7273
switch (fh->f_io_version) {
7374
case MCA_IO_BASE_V_2_0_0:
74-
rc = fh->f_io_selected_module.v2_0_0.
75-
io_module_file_iread_at_all(fh, offset, buf, count, datatype,
76-
request);
75+
if( OPAL_UNLIKELY(NULL == fh->f_io_selected_module.v2_0_0.io_module_file_iread_at_all) ) {
76+
rc = MPI_ERR_UNSUPPORTED_OPERATION;
77+
}
78+
else {
79+
rc = fh->f_io_selected_module.v2_0_0.
80+
io_module_file_iread_at_all(fh, offset, buf, count, datatype,
81+
request);
82+
}
7783
break;
7884

7985
default:

ompi/mpi/c/file_iwrite_all.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Copyright (c) 2015 University of Houston. All rights reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -75,8 +76,13 @@ int MPI_File_iwrite_all(MPI_File fh, const void *buf, int count, MPI_Datatype
7576
/* Call the back-end io component function */
7677
switch (fh->f_io_version) {
7778
case MCA_IO_BASE_V_2_0_0:
78-
rc = fh->f_io_selected_module.v2_0_0.
79-
io_module_file_iwrite_all(fh, buf, count, datatype, request);
79+
if( OPAL_UNLIKELY(NULL == fh->f_io_selected_module.v2_0_0.io_module_file_iwrite_all) ) {
80+
rc = MPI_ERR_UNSUPPORTED_OPERATION;
81+
}
82+
else {
83+
rc = fh->f_io_selected_module.v2_0_0.
84+
io_module_file_iwrite_all(fh, buf, count, datatype, request);
85+
}
8086
break;
8187

8288
default:

ompi/mpi/c/file_iwrite_at_all.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Copyright (c) 2015 University of Houston. All rights reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -76,9 +77,14 @@ int MPI_File_iwrite_at_all(MPI_File fh, MPI_Offset offset, const void *buf,
7677
/* Call the back-end io component function */
7778
switch (fh->f_io_version) {
7879
case MCA_IO_BASE_V_2_0_0:
79-
rc = fh->f_io_selected_module.v2_0_0.
80-
io_module_file_iwrite_at_all(fh, offset, buf, count, datatype,
81-
request);
80+
if( OPAL_UNLIKELY(NULL == fh->f_io_selected_module.v2_0_0.io_module_file_iwrite_at_all) ) {
81+
rc = MPI_ERR_UNSUPPORTED_OPERATION;
82+
}
83+
else {
84+
rc = fh->f_io_selected_module.v2_0_0.
85+
io_module_file_iwrite_at_all(fh, offset, buf, count, datatype,
86+
request);
87+
}
8288
break;
8389

8490
default:

0 commit comments

Comments
 (0)