[mpich-devel] lockcontention3.c bug

Archer, Charles J charles.j.archer at intel.com
Wed Sep 24 16:36:32 CDT 2014


I think I found a bug in lockcontention3.c:

Line 126, MPI_Win_create creates a window of size RMA_SIZE (2048 bytes).

Then, in case 9 of RMATest (line 249):
 MPI_Put( source, longcount, MPI_INT, master,
                 OFFSET_1, longcount, MPI_INT, win );

longcount is 512
OFFSET_1 is 7

longcount * sizeof(int) + OFFSET_1 is > 2048, and we have a buffer overrun.

I think on some platforms this test case will still work since the memory we are talking about is less than a page.
I didn’t check the other tests for the same problem yet.

Here’s a fix:

diff --git a/test/mpi/rma/lockcontention3.c b/test/mpi/rma/lockcontention3.c
index d70e26c..f42ff62 100644
--- a/test/mpi/rma/lockcontention3.c
+++ b/test/mpi/rma/lockcontention3.c
@@ -123,7 +123,7 @@ int main( int argc, char *argv[] )
     srcbuf = malloc(RMA_SIZE*sizeof(*srcbuf));
     assert(srcbuf);
 
-    MPI_Win_create( rmabuffer, bufsize, sizeof(int), MPI_INFO_NULL,
+    MPI_Win_create( rmabuffer, bufsize*sizeof(int), sizeof(int), MPI_INFO_NULL,
                    MPI_COMM_WORLD, &win );
     
     /* Run a sequence of tests */




More information about the devel mailing list