[mpich2-dev] [PATCH 1/1] Issue 4120:Read/write size error checking.
Bob Cernohous
bobc at us.ibm.com
Thu Mar 20 16:31:44 CDT 2008
I'm not sure about this one. I'm bothered when i see
count*datatype_size in the code and I imagine a >= 2G total
size that causes odd problems later. So I added error
checking up front. (This is different from writing/reading
data at >= 2G offsets in a file which we're trying to support.)
For you review and approval. I've kept the patch separate so
I can easily add or remove it.
Signed-off-by: Bob Cernohous <bobc at us.ibm.com>
---
.../src/mpi/romio/adio/include/adioi_error.h | 11 +++++++++++
lib/mpi/mpich2/src/mpi/romio/mpi-io/iread.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/iread_sh.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/iwrite.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/iwrite_sh.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/read.c | 5 +++++
lib/mpi/mpich2/src/mpi/romio/mpi-io/read_all.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/read_allb.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/read_ord.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/read_ordb.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/read_sh.c | 5 +++++
lib/mpi/mpich2/src/mpi/romio/mpi-io/write.c | 5 +++++
lib/mpi/mpich2/src/mpi/romio/mpi-io/write_all.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/write_allb.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/write_ord.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/write_ordb.c | 1 +
lib/mpi/mpich2/src/mpi/romio/mpi-io/write_sh.c | 5 +++++
17 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/lib/mpi/mpich2/src/mpi/romio/adio/include/adioi_error.h b/lib/mpi/mpich2/src/mpi/romio/adio/include/adioi_error.h
index f004639..3cbcf63 100644
--- a/lib/mpi/mpich2/src/mpi/romio/adio/include/adioi_error.h
+++ b/lib/mpi/mpich2/src/mpi/romio/adio/include/adioi_error.h
@@ -33,6 +33,17 @@ if (count < 0) { \
goto fn_exit; \
}
+#define MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code) \
+if (count*datatype_size != (ADIO_Offset)(unsigned)count*(ADIO_Offset)(unsigned)datatype_size) { \
+ error_code = MPIO_Err_create_code(MPI_SUCCESS, \
+ MPIR_ERR_RECOVERABLE, \
+ myname, __LINE__, \
+ MPI_ERR_ARG, \
+ "**iobadcount", 0); \
+ error_code = MPIO_Err_return_file(fh, error_code); \
+ goto fn_exit; \
+}
+
#define MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code) \
if (datatype == MPI_DATATYPE_NULL) { \
error_code = MPIO_Err_create_code(MPI_SUCCESS, \
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/iread.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/iread.c
index 3f64dc9..f2c9e1c 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/iread.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/iread.c
@@ -113,6 +113,7 @@ int MPIOI_File_iread(MPI_File mpi_fh,
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
MPIO_CHECK_READABLE(fh, myname, error_code);
MPIO_CHECK_NOT_SEQUENTIAL_MODE(fh, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/iread_sh.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/iread_sh.c
index d467511..56185fc 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/iread_sh.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/iread_sh.c
@@ -68,6 +68,7 @@ int MPI_File_iread_shared(MPI_File mpi_fh, void *buf, int count,
/* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
MPIO_CHECK_FS_SUPPORTS_SHARED(fh, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/iwrite.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/iwrite.c
index dd85962..c8dbec7 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/iwrite.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/iwrite.c
@@ -116,6 +116,7 @@ int MPIOI_File_iwrite(MPI_File mpi_fh,
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
MPIO_CHECK_WRITABLE(fh, myname, error_code);
MPIO_CHECK_NOT_SEQUENTIAL_MODE(fh, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/iwrite_sh.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/iwrite_sh.c
index 5c60df7..5da2062 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/iwrite_sh.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/iwrite_sh.c
@@ -67,6 +67,7 @@ int MPI_File_iwrite_shared(MPI_File mpi_fh, void *buf, int count,
/* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
MPIO_CHECK_FS_SUPPORTS_SHARED(fh, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read.c
index 0581ff3..e3a7e66 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read.c
@@ -96,6 +96,11 @@ int MPIOI_File_read(MPI_File mpi_fh,
/* --END ERROR HANDLING-- */
MPI_Type_size(datatype, &datatype_size);
+
+ /* --BEGIN ERROR HANDLING-- */
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
+ /* --END ERROR HANDLING-- */
+
if (count*datatype_size == 0)
{
#ifdef HAVE_STATUS_SET_BYTES
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_all.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_all.c
index 1aa271b..56b158d 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_all.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_all.c
@@ -101,6 +101,7 @@ int MPIOI_File_read_all(MPI_File mpi_fh,
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
MPIO_CHECK_READABLE(fh, myname, error_code);
MPIO_CHECK_NOT_SEQUENTIAL_MODE(fh, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
ADIO_ReadStridedColl(fh, buf, count, datatype, file_ptr_type,
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_allb.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_allb.c
index 6622618..f3811ed 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_allb.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_allb.c
@@ -96,6 +96,7 @@ int MPIOI_File_read_all_begin(MPI_File mpi_fh,
error_code = MPIO_Err_return_file(fh, error_code);
goto fn_exit;
}
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
fh->split_coll_count = 1;
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_ord.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_ord.c
index 826d11a..e338e20 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_ord.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_ord.c
@@ -64,6 +64,7 @@ int MPI_File_read_ordered(MPI_File mpi_fh, void *buf, int count,
/* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
MPIO_CHECK_FS_SUPPORTS_SHARED(fh, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
ADIOI_TEST_DEFERRED(fh, "MPI_File_read_ordered", &error_code);
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_ordb.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_ordb.c
index 0d3386c..e4655e1 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_ordb.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_ordb.c
@@ -72,6 +72,7 @@ int MPI_File_read_ordered_begin(MPI_File mpi_fh, void *buf, int count,
/* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
MPIO_CHECK_FS_SUPPORTS_SHARED(fh, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
ADIOI_TEST_DEFERRED(fh, myname, &error_code);
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_sh.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_sh.c
index b2507bf..31e26e1 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_sh.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/read_sh.c
@@ -60,6 +60,11 @@ int MPI_File_read_shared(MPI_File mpi_fh, void *buf, int count,
/* --END ERROR HANDLING-- */
MPI_Type_size(datatype, &datatype_size);
+
+ /* --BEGIN ERROR HANDLING-- */
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
+ /* --END ERROR HANDLING-- */
+
if (count*datatype_size == 0)
{
#ifdef HAVE_STATUS_SET_BYTES
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write.c
index 9ba2bef..ac48131 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write.c
@@ -96,6 +96,11 @@ int MPIOI_File_write(MPI_File mpi_fh,
/* --END ERROR HANDLING-- */
MPI_Type_size(datatype, &datatype_size);
+
+ /* --BEGIN ERROR HANDLING-- */
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
+ /* --END ERROR HANDLING-- */
+
if (count*datatype_size == 0)
{
#ifdef HAVE_STATUS_SET_BYTES
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_all.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_all.c
index 4ced9d4..b34040a 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_all.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_all.c
@@ -101,6 +101,7 @@ int MPIOI_File_write_all(MPI_File mpi_fh,
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
MPIO_CHECK_WRITABLE(fh, myname, error_code);
MPIO_CHECK_NOT_SEQUENTIAL_MODE(fh, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
ADIO_WriteStridedColl(fh, buf, count, datatype, file_ptr_type,
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_allb.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_allb.c
index 4559f9e..bcb379c 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_allb.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_allb.c
@@ -96,6 +96,7 @@ int MPIOI_File_write_all_begin(MPI_File mpi_fh,
MPI_Type_size(datatype, &datatype_size);
/* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
fh->split_datatype = datatype;
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_ord.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_ord.c
index ad3d6cf..7c6f43e 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_ord.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_ord.c
@@ -64,6 +64,7 @@ int MPI_File_write_ordered(MPI_File mpi_fh, void *buf, int count,
/* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
MPIO_CHECK_FS_SUPPORTS_SHARED(fh, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
ADIOI_TEST_DEFERRED(fh, myname, &error_code);
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_ordb.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_ordb.c
index 7253d32..498c44f 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_ordb.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_ordb.c
@@ -71,6 +71,7 @@ int MPI_File_write_ordered_begin(MPI_File mpi_fh, void *buf, int count,
/* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
MPIO_CHECK_FS_SUPPORTS_SHARED(fh, myname, error_code);
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
/* --END ERROR HANDLING-- */
ADIOI_TEST_DEFERRED(fh, myname, &error_code);
diff --git a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_sh.c b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_sh.c
index 47fd9cd..f5bd7b8 100644
--- a/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_sh.c
+++ b/lib/mpi/mpich2/src/mpi/romio/mpi-io/write_sh.c
@@ -60,6 +60,11 @@ int MPI_File_write_shared(MPI_File mpi_fh, void *buf, int count,
/* --END ERROR HANDLING-- */
MPI_Type_size(datatype, &datatype_size);
+
+ /* --BEGIN ERROR HANDLING-- */
+ MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
+ /* --END ERROR HANDLING-- */
+
if (count*datatype_size == 0) {
#ifdef HAVE_STATUS_SET_BYTES
MPIR_Status_set_bytes(status, datatype, 0);
--
1.5.3.7
More information about the mpich2-dev
mailing list