[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.2-211-gee52b6b

Service Account noreply at mpich.org
Fri Feb 19 16:38:55 CST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".

The branch, master has been updated
       via  ee52b6b8ae093174384e7fc3e8da990ab1a6e0ac (commit)
       via  b7db27e2b52595ce089f0cd81a1ed89e4e31056e (commit)
      from  0e37fd5d6c375aeb7d00eaaae23d709af1c88388 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/ee52b6b8ae093174384e7fc3e8da990ab1a6e0ac

commit ee52b6b8ae093174384e7fc3e8da990ab1a6e0ac
Author: Yanfei Guo <yguo at anl.gov>
Date:   Thu Feb 18 16:05:41 2016 -0600

    cleanup mixed indentation and white spaces
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/test/mpi/cxx/pt2pt/sendrecvx.cxx b/test/mpi/cxx/pt2pt/sendrecvx.cxx
index 2125984..bd3b990 100644
--- a/test/mpi/cxx/pt2pt/sendrecvx.cxx
+++ b/test/mpi/cxx/pt2pt/sendrecvx.cxx
@@ -37,27 +37,27 @@ int main( int argc, char *argv[] )
     size = MPI::COMM_WORLD.Get_size();
 
     if (size < 2) {
-	cerr << "Size of comm_world must be at least 2\n";
-	MPI::COMM_WORLD.Abort(1);
+        cerr << "Size of comm_world must be at least 2\n";
+        MPI::COMM_WORLD.Abort(1);
     }
     if (rank == 0) {
-	int *buf = new int[100];
-	int i;
-	for (i=0; i<100; i++) buf[i] = i;
-	MPI::COMM_WORLD.Send( buf, 100, MPI::INT, size-1, 0 );
-    delete[] buf;
+        int *buf = new int[100];
+        int i;
+        for (i=0; i<100; i++) buf[i] = i;
+        MPI::COMM_WORLD.Send( buf, 100, MPI::INT, size-1, 0 );
+        delete[] buf;
     }
     else if (rank == size - 1) {
-	int *buf = new int[100];
-	int i;
-	MPI::COMM_WORLD.Recv( buf, 100, MPI::INT, 0, 0 );
-	for (i=0; i<100; i++) {
-	    if (buf[i] != i) {
-		errs++;
-		cerr << "Error: buf[" << i << "] = " << buf[i] << "\n";
-	    }
-	}
-    delete[] buf;
+        int *buf = new int[100];
+        int i;
+        MPI::COMM_WORLD.Recv( buf, 100, MPI::INT, 0, 0 );
+        for (i=0; i<100; i++) {
+            if (buf[i] != i) {
+                errs++;
+                cerr << "Error: buf[" << i << "] = " << buf[i] << "\n";
+            }
+        }
+        delete[] buf;
     }
 
     MTest_Finalize( errs );

http://git.mpich.org/mpich.git/commitdiff/b7db27e2b52595ce089f0cd81a1ed89e4e31056e

commit b7db27e2b52595ce089f0cd81a1ed89e4e31056e
Author: Yanfei Guo <yguo at anl.gov>
Date:   Wed Feb 10 18:13:47 2016 -0600

    Fix Valgrind errors
    
    1. Memory leaks due to missing free or delete.
    2. False-positive due to unintialized padding (bug of valgrind). Two
    macros are added for mem init in MPI library and test.
    3. Uninitialized value in some test.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpi/rma/alloc_mem.c b/src/mpi/rma/alloc_mem.c
index 3660e25..367f2f5 100644
--- a/src/mpi/rma/alloc_mem.c
+++ b/src/mpi/rma/alloc_mem.c
@@ -100,6 +100,7 @@ int MPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr)
     }
     /* --END ERROR HANDLING-- */
 
+    MPL_VG_MEM_INIT(ap, size);
     *(void **)baseptr = ap;
 
     /* ... end of body of routine ... */
diff --git a/src/mpi/romio/adio/common/malloc.c b/src/mpi/romio/adio/common/malloc.c
index 7f3462b..f0838e1 100644
--- a/src/mpi/romio/adio/common/malloc.c
+++ b/src/mpi/romio/adio/common/malloc.c
@@ -60,6 +60,7 @@ void *ADIOI_Malloc_fn(size_t size, int lineno, const char *fname)
 	FPRINTF(stderr, "Out of memory in file %s, line %d\n", fname, lineno);
 	MPI_Abort(MPI_COMM_WORLD, 1);
     }
+    MPL_VG_MEM_INIT(new, size);
     DBG_FPRINTF(stderr, "ADIOI_Malloc %s:<%d> %p (%#zX)\n", fname, lineno, new, size);
     return new;
 }
diff --git a/src/mpi/spawn/comm_join.c b/src/mpi/spawn/comm_join.c
index 62ddb3c..8d6655b 100644
--- a/src/mpi/spawn/comm_join.c
+++ b/src/mpi/spawn/comm_join.c
@@ -151,6 +151,8 @@ int MPI_Comm_join(int fd, MPI_Comm *intercomm)
     
     MPIU_CHKLMEM_MALLOC(local_port, char *, MPI_MAX_PORT_NAME, mpi_errno, "local port name");
     MPIU_CHKLMEM_MALLOC(remote_port, char *, MPI_MAX_PORT_NAME, mpi_errno, "remote port name");
+
+    MPL_VG_MEM_INIT(local_port, MPI_MAX_PORT_NAME * sizeof(char));
     
     mpi_errno = MPIR_Open_port_impl(NULL, local_port);
     MPIR_ERR_CHKANDJUMP((mpi_errno != MPI_SUCCESS), mpi_errno, MPI_ERR_OTHER, "**openportfailed");
diff --git a/src/mpi/topo/topoutil.c b/src/mpi/topo/topoutil.c
index 46ec563..9bb2638 100644
--- a/src/mpi/topo/topoutil.c
+++ b/src/mpi/topo/topoutil.c
@@ -145,6 +145,8 @@ static int MPIR_Topology_copy_fn ( MPI_Comm comm ATTRIBUTE((unused)),
 
     MPIU_CHKPMEM_MALLOC(copy_topology, MPIR_Topology *, sizeof(MPIR_Topology), mpi_errno, "copy_topology");
 
+    MPL_VG_MEM_INIT(copy_topology, sizeof(MPIR_Topology));
+
     /* simplify copying and error handling */
 #define MPIR_ARRAY_COPY_HELPER(kind_,array_field_,count_field_) \
         do { \
diff --git a/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.c b/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.c
index 06d19e8..ee592cf 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.c
@@ -476,18 +476,7 @@ static int send_id_info(const sockconn_t *const sc)
 /*     FIXME better keep pg_id_len itself as part of MPIDI_Process.my_pg structure to */
 /*     avoid computing the length of string everytime this function is called. */
 
-#if defined(MPL_VG_AVAILABLE)
-    /* Valgrind has a bug
-     * (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=524488) that
-     * causes it to report a warning when we initialize the compiler
-     * adds padding to structures.  Even when we initialize all the
-     * fields, the padding bytes are not initialized.  The idea here
-     * is to detect when we are in "valgrind mode" and in such cases
-     * initialize all bytes of the structure. */
-    if (MPL_VG_RUNNING_ON_VALGRIND()) {
-        memset(&hdr, 0, sizeof(hdr));
-    }
-#endif
+    MPL_VG_MEM_INIT(&hdr, sizeof(hdr));
     
     hdr.pkt_type = MPIDI_NEM_TCP_SOCKSM_PKT_ID_INFO;
     hdr.datalen = sizeof(MPIDI_nem_tcp_idinfo_t) + pg_id_len;    
@@ -545,6 +534,8 @@ static int send_tmpvc_info(const sockconn_t *const sc)
 /*     store ending NULL also */
 /*     FIXME better keep pg_id_len itself as part of MPIDI_Process.my_pg structure to */
 /*     avoid computing the length of string everytime this function is called. */
+
+    MPL_VG_MEM_INIT(&hdr, sizeof(hdr));
     
     hdr.pkt_type = MPIDI_NEM_TCP_SOCKSM_PKT_TMPVC_INFO;
     hdr.datalen = sizeof(MPIDI_nem_tcp_portinfo_t);
@@ -724,18 +715,7 @@ static int send_cmd_pkt(int fd, MPIDI_nem_tcp_socksm_pkt_type_t pkt_type)
 		pkt_type == MPIDI_NEM_TCP_SOCKSM_PKT_TMPVC_NAK ||
                 pkt_type == MPIDI_NEM_TCP_SOCKSM_PKT_CLOSED);
 
-#if defined(MPL_VG_AVAILABLE)
-    /* Valgrind has a bug
-     * (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=524488) that
-     * causes it to report a warning when we initialize the compiler
-     * adds padding to structures.  Even when we initialize all the
-     * fields, the padding bytes are not initialized.  The idea here
-     * is to detect when we are in "valgrind mode" and in such cases
-     * initialize all bytes of the structure. */
-    if (MPL_VG_RUNNING_ON_VALGRIND()) {
-        memset(&pkt, 0, sizeof(pkt));
-    }
-#endif
+    MPL_VG_MEM_INIT(&pkt, sizeof(pkt));
 
     pkt.pkt_type = pkt_type;
     pkt.datalen = 0;
diff --git a/src/mpid/ch3/include/mpid_rma_issue.h b/src/mpid/ch3/include/mpid_rma_issue.h
index 41c0b29..a852550 100644
--- a/src/mpid/ch3/include/mpid_rma_issue.h
+++ b/src/mpid/ch3/include/mpid_rma_issue.h
@@ -119,6 +119,7 @@ static int init_accum_ext_pkt(MPIDI_CH3_Pkt_flags_t flags,
         _total_sz = _ext_hdr_sz + target_dtp->dataloop_size;
 
         _ext_hdr_ptr = (MPIDI_CH3_Ext_pkt_accum_stream_derived_t *) MPL_malloc(_total_sz);
+        MPL_VG_MEM_INIT(_ext_hdr_ptr, _total_sz);
         if (_ext_hdr_ptr == NULL) {
             MPIR_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**nomem",
                                  "**nomem %s", "MPIDI_CH3_Ext_pkt_accum_stream_derived_t");
@@ -137,6 +138,7 @@ static int init_accum_ext_pkt(MPIDI_CH3_Pkt_flags_t flags,
         _total_sz = sizeof(MPIDI_CH3_Ext_pkt_accum_stream_t);
 
         _ext_hdr_ptr = (MPIDI_CH3_Ext_pkt_accum_stream_t *) MPL_malloc(_total_sz);
+        MPL_VG_MEM_INIT(_ext_hdr_ptr, _total_sz);
         if (_ext_hdr_ptr == NULL) {
             MPIR_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**nomem",
                                  "**nomem %s", "MPIDI_CH3_Ext_pkt_accum_stream_t");
@@ -154,6 +156,7 @@ static int init_accum_ext_pkt(MPIDI_CH3_Pkt_flags_t flags,
         _total_sz = _ext_hdr_sz + target_dtp->dataloop_size;
 
         _ext_hdr_ptr = (MPIDI_CH3_Ext_pkt_accum_derived_t *) MPL_malloc(_total_sz);
+        MPL_VG_MEM_INIT(_ext_hdr_ptr, _total_sz);
         if (_ext_hdr_ptr == NULL) {
             MPIR_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**nomem",
                                  "**nomem %s", "MPIDI_CH3_Ext_pkt_accum_derived_t");
@@ -433,6 +436,7 @@ static int issue_put_op(MPIDI_RMA_Op_t * rma_op, MPID_Win * win_ptr,
              * TODO: support extended header array */
             ext_hdr_sz = sizeof(MPIDI_CH3_Ext_pkt_put_derived_t) + target_dtp_ptr->dataloop_size;
             ext_hdr_ptr = MPL_malloc(ext_hdr_sz);
+            MPL_VG_MEM_INIT(ext_hdr_ptr, ext_hdr_sz);
             if (!ext_hdr_ptr) {
                 MPIR_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**nomem",
                                      "**nomem %s", "MPIDI_CH3_Ext_pkt_put_derived_t");
@@ -938,6 +942,7 @@ static int issue_get_op(MPIDI_RMA_Op_t * rma_op, MPID_Win * win_ptr,
          * TODO: support extended header array */
         ext_hdr_sz = sizeof(MPIDI_CH3_Ext_pkt_get_derived_t) + dtp->dataloop_size;
         ext_hdr_ptr = MPL_malloc(ext_hdr_sz);
+        MPL_VG_MEM_INIT(ext_hdr_ptr, ext_hdr_sz);
         if (!ext_hdr_ptr) {
             MPIR_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**nomem",
                                  "**nomem %s", "MPIDI_CH3_Ext_pkt_get_derived_t");
diff --git a/src/mpid/ch3/src/ch3u_win_fns.c b/src/mpid/ch3/src/ch3u_win_fns.c
index a1eb3a9..f35cb59 100644
--- a/src/mpid/ch3/src/ch3u_win_fns.c
+++ b/src/mpid/ch3/src/ch3u_win_fns.c
@@ -256,6 +256,7 @@ int MPIDI_CH3U_Win_allocate_no_shm(MPI_Aint size, int disp_unit, MPID_Info * inf
 
     if (size > 0) {
         MPIU_CHKPMEM_MALLOC(*base_pp, void *, size, mpi_errno, "(*win_ptr)->base");
+        MPL_VG_MEM_INIT(*base_pp, size);
     }
     else if (size == 0) {
         *base_pp = NULL;
diff --git a/src/mpl/include/mpl_valgrind.h b/src/mpl/include/mpl_valgrind.h
index ca83df8..b902b5c 100644
--- a/src/mpl/include/mpl_valgrind.h
+++ b/src/mpl/include/mpl_valgrind.h
@@ -138,6 +138,14 @@
 #  define MPL_VG_CREATE_BLOCK(addr_,len_,desc_)       do { (void) VALGRIND_CREATE_BLOCK((addr_),(len_),(desc_)); } while (0)
 #  define MPL_VG_RUNNING_ON_VALGRIND()                RUNNING_ON_VALGRIND
 #  define MPL_VG_PRINTF_BACKTRACE                     VALGRIND_PRINTF_BACKTRACE
+/* Valgrind has a bug
+ * (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=524488) that
+ * causes it to report a warning when the compiler adds padding to
+ * structures.  Even when we initialize all the fields in the
+ * structure, the padding bytes are not initialized.  The idea here is
+ * to detect when we are in "valgrind mode" and in such cases
+ * initialize all bytes of the structure. */
+#  define MPL_VG_MEM_INIT(addr_,len_)                 do { memset(addr_, 0, len_); } while (0)
 
 /* custom allocator client requests, you probably shouldn't use these unless you
  * really know what you are doing */
@@ -154,6 +162,7 @@
 #  define MPL_VG_CHECK_MEM_IS_ADDRESSABLE(addr_,len_) do {} while (0)
 #  define MPL_VG_CREATE_BLOCK(addr_,len_,desc_)       do {} while (0)
 #  define MPL_VG_RUNNING_ON_VALGRIND()                (0)       /*always false */
+#  define MPL_VG_MEM_INIT(addr_,len_)                 do {} while (0)
 #  if defined(MPL_HAVE_MACRO_VA_ARGS)
 #    define MPL_VG_PRINTF_BACKTRACE(...)              do {} while (0)
 #  else
diff --git a/test/mpi/coll/bcastzerotype.c b/test/mpi/coll/bcastzerotype.c
index 9ea8fc4..d6716d4 100644
--- a/test/mpi/coll/bcastzerotype.c
+++ b/test/mpi/coll/bcastzerotype.c
@@ -47,6 +47,8 @@ int main(int argc, char *argv[])
         assert(buf[i] == wrank * NELEM + i);
     }
 
+    free(buf);
+
     MPI_Type_free(&type);
     MPI_Finalize();
 
diff --git a/test/mpi/coll/nonblocking.c b/test/mpi/coll/nonblocking.c
index 9942b2b..057480b 100644
--- a/test/mpi/coll/nonblocking.c
+++ b/test/mpi/coll/nonblocking.c
@@ -204,6 +204,8 @@ int main(int argc, char **argv)
         free(sdispls);
     if (rdispls)
         free(rdispls);
+    if (types)
+        free(types);
 
     if (rank == 0) {
         if (errs)
diff --git a/test/mpi/coll/opland.c b/test/mpi/coll/opland.c
index 52970df..e419174 100644
--- a/test/mpi/coll/opland.c
+++ b/test/mpi/coll/opland.c
@@ -202,6 +202,7 @@ int main(int argc, char *argv[])
     {
         long double ldinbuf[3], ldoutbuf[3];
         /* long double */
+        MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0]));
         ldinbuf[0] = 1;
         ldinbuf[1] = 0;
         ldinbuf[2] = (rank > 0);
diff --git a/test/mpi/coll/oplor.c b/test/mpi/coll/oplor.c
index c53c5c6..14fafd2 100644
--- a/test/mpi/coll/oplor.c
+++ b/test/mpi/coll/oplor.c
@@ -205,6 +205,7 @@ int main(int argc, char *argv[])
     {
         long double ldinbuf[3], ldoutbuf[3];
         /* long double */
+        MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0]));
         ldinbuf[0] = 1;
         ldinbuf[1] = 0;
         ldinbuf[2] = (rank > 0);
diff --git a/test/mpi/coll/oplxor.c b/test/mpi/coll/oplxor.c
index 03de2c4..f5099b8 100644
--- a/test/mpi/coll/oplxor.c
+++ b/test/mpi/coll/oplxor.c
@@ -202,6 +202,7 @@ int main(int argc, char *argv[])
     {
         long double ldinbuf[3], ldoutbuf[3];
         /* long double */
+        MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0]));
         ldinbuf[0] = 1;
         ldinbuf[1] = 0;
         ldinbuf[2] = (rank > 0);
diff --git a/test/mpi/coll/opmax.c b/test/mpi/coll/opmax.c
index 0a52ed3..cc8049b 100644
--- a/test/mpi/coll/opmax.c
+++ b/test/mpi/coll/opmax.c
@@ -115,6 +115,7 @@ int main(int argc, char *argv[])
     {
         long double ldinbuf[3], ldoutbuf[3];
         /* long double */
+        MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0]));
         ldinbuf[0] = 1;
         ldinbuf[1] = 0;
         ldinbuf[2] = rank;
diff --git a/test/mpi/coll/opmin.c b/test/mpi/coll/opmin.c
index 9f80256..bc758a5 100644
--- a/test/mpi/coll/opmin.c
+++ b/test/mpi/coll/opmin.c
@@ -115,6 +115,7 @@ int main(int argc, char *argv[])
     {
         long double ldinbuf[3], ldoutbuf[3];
         /* long double */
+        MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0]));
         ldinbuf[0] = 1;
         ldinbuf[1] = 0;
         ldinbuf[2] = rank;
diff --git a/test/mpi/coll/opminloc.c b/test/mpi/coll/opminloc.c
index 29ced04..b7f047c 100644
--- a/test/mpi/coll/opminloc.c
+++ b/test/mpi/coll/opminloc.c
@@ -226,6 +226,7 @@ int main(int argc, char *argv[])
             long double val;
             int loc;
         } cinbuf[3], coutbuf[3];
+        MTEST_VG_MEM_INIT(cinbuf, 3* sizeof(cinbuf[0]));
 
         cinbuf[0].val = 1;
         cinbuf[0].loc = rank;
diff --git a/test/mpi/coll/opprod.c b/test/mpi/coll/opprod.c
index 0d25f3a..9c8001e 100644
--- a/test/mpi/coll/opprod.c
+++ b/test/mpi/coll/opprod.c
@@ -138,6 +138,7 @@ int main(int argc, char *argv[])
         int dc;
 #ifdef HAVE_LONG_DOUBLE
         ld_complex ldinbuf[3], ldoutbuf[3];
+        MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0]));
 #endif
         /* Must determine which C type matches this Fortran type */
         MPI_Type_size(MPI_DOUBLE_COMPLEX, &dc);
@@ -257,6 +258,7 @@ int main(int argc, char *argv[])
 #ifdef HAVE_LONG_DOUBLE
     {
         long double ldinbuf[3], ldoutbuf[3];
+        MTEST_VG_MEM_INIT(ldinbuf, 3 * sizeof(ldinbuf[0]));
         /* long double */
         ldinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
         ldinbuf[1] = 0;
diff --git a/test/mpi/coll/opsum.c b/test/mpi/coll/opsum.c
index 636c001..cad22f3 100644
--- a/test/mpi/coll/opsum.c
+++ b/test/mpi/coll/opsum.c
@@ -127,6 +127,7 @@ int main(int argc, char *argv[])
         int dc;
 #ifdef HAVE_LONG_DOUBLE
         ld_complex ldinbuf[3], ldoutbuf[3];
+        MTEST_VG_MEM_INIT(ldinbuf, 3 * sizeof(ldinbuf[0]));
 #endif
         /* Must determine which C type matches this Fortran type */
         MPI_Type_size(MPI_DOUBLE_COMPLEX, &dc);
@@ -203,6 +204,7 @@ int main(int argc, char *argv[])
 #ifdef HAVE_LONG_DOUBLE
     {
         long double ldinbuf[3], ldoutbuf[3];
+        MTEST_VG_MEM_INIT(ldinbuf, 3 * sizeof(ldinbuf[0]));
         /* long double */
         ldinbuf[0] = 1;
         ldinbuf[1] = 0;
diff --git a/test/mpi/coll/redscat.c b/test/mpi/coll/redscat.c
index 75bb5a4..bfa2987 100644
--- a/test/mpi/coll/redscat.c
+++ b/test/mpi/coll/redscat.c
@@ -51,6 +51,9 @@ int main(int argc, char **argv)
     if (rank == 0 && toterr == 0) {
         printf(" No Errors\n");
     }
+
+    free(sendbuf);
+    free(recvcounts);
     MPI_Finalize();
 
     return toterr;
diff --git a/test/mpi/coll/redscat2.c b/test/mpi/coll/redscat2.c
index 2c01ba7..4c14537 100644
--- a/test/mpi/coll/redscat2.c
+++ b/test/mpi/coll/redscat2.c
@@ -115,6 +115,7 @@ int main(int argc, char **argv)
 
         free(recvbuf);
         free(sendbuf);
+        free(recvcounts);
     }
 
     MPI_Op_free(&left_op);
diff --git a/test/mpi/coll/scatter3.c b/test/mpi/coll/scatter3.c
index c83e413..84e88bb 100644
--- a/test/mpi/coll/scatter3.c
+++ b/test/mpi/coll/scatter3.c
@@ -79,6 +79,8 @@ int main(int argc, char **argv)
         }
     }
 
+    free(vecin);
+    free(vecout);
     MTest_Finalize(errs);
     MPI_Type_free(&vec);
     MPI_Finalize();
diff --git a/test/mpi/coll/scattern.c b/test/mpi/coll/scattern.c
index 5bc2fc4..2a3b305 100644
--- a/test/mpi/coll/scattern.c
+++ b/test/mpi/coll/scattern.c
@@ -52,6 +52,8 @@ int main(int argc, char **argv)
         else
             printf(" No Errors\n");
     }
+    free(vecin);
+    free(vecout);
     MPI_Type_free(&vec);
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/comm/comm_create_group.c b/test/mpi/comm/comm_create_group.c
index ee0a8df..3c4553f 100644
--- a/test/mpi/comm/comm_create_group.c
+++ b/test/mpi/comm/comm_create_group.c
@@ -51,6 +51,7 @@ int main(int argc, char *argv[])
     if (rank == 0)
         printf(" No errors\n");
 
+    free(excl);
     MPI_Finalize();
     return 0;
 }
diff --git a/test/mpi/comm/comm_group_rand.c b/test/mpi/comm/comm_group_rand.c
index 7f609c0..90d143a 100644
--- a/test/mpi/comm/comm_group_rand.c
+++ b/test/mpi/comm/comm_group_rand.c
@@ -55,6 +55,8 @@ int main(int argc, char **argv)
     if (rank == 0)
         printf(" No Errors\n");
 
+    free(ranks);
+    free(included);
     MPI_Finalize();
 
     return 0;
diff --git a/test/mpi/comm/comm_idup_isend.c b/test/mpi/comm/comm_idup_isend.c
index bb5d3b5..38b3b73 100644
--- a/test/mpi/comm/comm_idup_isend.c
+++ b/test/mpi/comm/comm_idup_isend.c
@@ -102,6 +102,7 @@ int main(int argc, char **argv)
         MTestFreeComm(&testcomm);
     }
 
+    free(sreq);
     MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/cxx/coll/arcomplex.cxx b/test/mpi/cxx/coll/arcomplex.cxx
index 11a8177..e347c43 100644
--- a/test/mpi/cxx/coll/arcomplex.cxx
+++ b/test/mpi/cxx/coll/arcomplex.cxx
@@ -31,6 +31,7 @@ int main( int argc, char **argv )
     complex<double> cd[2], cd_out[2];
 #ifdef HAVE_LONG_DOUBLE
     complex<long double> cld[2], cld_out[2];
+    MTEST_VG_MEM_INIT(cld, 2 * sizeof(complex<long double>));
 #endif
 
     MTest_Init( );
diff --git a/test/mpi/cxx/comm/commname2.cxx b/test/mpi/cxx/comm/commname2.cxx
index 56febbf..16890b1 100644
--- a/test/mpi/cxx/comm/commname2.cxx
+++ b/test/mpi/cxx/comm/commname2.cxx
@@ -74,7 +74,7 @@ int main( int argc, char **argv )
 	    errs++;
 	    cout << "comm[" << i << "] gave name " << name << "\n";
 	}
-        MTestFreeComm ( *comm[i] );
+        MTestFreeComm ( comm[i] );
     }
     
     MTest_Finalize( errs );
diff --git a/test/mpi/cxx/io/filemiscx.cxx b/test/mpi/cxx/io/filemiscx.cxx
index ccb04e4..7e00158 100644
--- a/test/mpi/cxx/io/filemiscx.cxx
+++ b/test/mpi/cxx/io/filemiscx.cxx
@@ -38,6 +38,8 @@ int main(int argc, char **argv)
     MPI::Datatype etype, filetype;
     char datarep[25], *filename;
 
+    MTEST_VG_MEM_INIT(buf, 1024 * sizeof(int));
+
     MPI::Init();
 
     try {
diff --git a/test/mpi/cxx/pt2pt/bsend1cxx.cxx b/test/mpi/cxx/pt2pt/bsend1cxx.cxx
index ea299f4..320465b 100644
--- a/test/mpi/cxx/pt2pt/bsend1cxx.cxx
+++ b/test/mpi/cxx/pt2pt/bsend1cxx.cxx
@@ -103,7 +103,7 @@ int main( int argc, char *argv[] )
 	cerr << "Returned buffer from detach is not the same as the initial buffer\n";
     }
 
-    delete buf;
+    delete[] buf;
 
     MTest_Finalize( errs );
 
diff --git a/test/mpi/cxx/pt2pt/sendrecvx.cxx b/test/mpi/cxx/pt2pt/sendrecvx.cxx
index 8931f94..2125984 100644
--- a/test/mpi/cxx/pt2pt/sendrecvx.cxx
+++ b/test/mpi/cxx/pt2pt/sendrecvx.cxx
@@ -45,6 +45,7 @@ int main( int argc, char *argv[] )
 	int i;
 	for (i=0; i<100; i++) buf[i] = i;
 	MPI::COMM_WORLD.Send( buf, 100, MPI::INT, size-1, 0 );
+    delete[] buf;
     }
     else if (rank == size - 1) {
 	int *buf = new int[100];
@@ -56,6 +57,7 @@ int main( int argc, char *argv[] )
 		cerr << "Error: buf[" << i << "] = " << buf[i] << "\n";
 	    }
 	}
+    delete[] buf;
     }
 
     MTest_Finalize( errs );
diff --git a/test/mpi/cxx/spawn/selfconaccx.cxx b/test/mpi/cxx/spawn/selfconaccx.cxx
index a11c60c..76a50c7 100644
--- a/test/mpi/cxx/spawn/selfconaccx.cxx
+++ b/test/mpi/cxx/spawn/selfconaccx.cxx
@@ -26,6 +26,8 @@ int main( int argc, char *argv[] )
     MPI::Status status;
     MPI::Intercomm comm;
 
+    MTEST_VG_MEM_INIT(port, MPI_MAX_PORT_NAME * sizeof(char));
+
     MPI::Init(argc, argv);
 
     size = MPI::COMM_WORLD.Get_size();
diff --git a/test/mpi/datatype/getpartelm.c b/test/mpi/datatype/getpartelm.c
index 8f7000f..b2205c5 100644
--- a/test/mpi/datatype/getpartelm.c
+++ b/test/mpi/datatype/getpartelm.c
@@ -6,6 +6,7 @@
  */
 #include "mpi.h"
 #include <stdio.h>
+#include <string.h>
 #include "mpitest.h"
 
 /*
@@ -40,6 +41,7 @@ int main(int argc, char *argv[])
 
     if (rank == src) {
         int buf[128], position, cnt;
+        MTEST_VG_MEM_INIT(buf, 128 * sizeof(buf[0]));
         /* sender */
 
         /* Create a datatype and send it (multiple of sizeof(int)) */
diff --git a/test/mpi/datatype/large_type.c b/test/mpi/datatype/large_type.c
index 687f31b..48a256d 100644
--- a/test/mpi/datatype/large_type.c
+++ b/test/mpi/datatype/large_type.c
@@ -81,6 +81,8 @@ static MPI_Datatype make_largexfer_type_hindexed(MPI_Offset nbytes)
     MPI_Type_create_hindexed(count, blocklens, disp, MPI_BYTE, &memtype);
     MPI_Type_commit(&memtype);
 
+    free(blocklens);
+    free(disp);
     return memtype;
 }
 
diff --git a/test/mpi/datatype/large_vec.c b/test/mpi/datatype/large_vec.c
index 0b7eafb..a009ee1 100644
--- a/test/mpi/datatype/large_vec.c
+++ b/test/mpi/datatype/large_vec.c
@@ -74,6 +74,7 @@ int main(int argc, char *argv[])
     }
 
     MPI_Type_free(&dtype);
+    free(cols);
 
     MTest_Finalize(errs);
     MPI_Finalize();
diff --git a/test/mpi/datatype/simple-pack-external.c b/test/mpi/datatype/simple-pack-external.c
index ce67a32..73cce40 100644
--- a/test/mpi/datatype/simple-pack-external.c
+++ b/test/mpi/datatype/simple-pack-external.c
@@ -178,6 +178,7 @@ int vector_of_vectors_test(void)
         }
     }
 
+    free(buf);
     MPI_Type_free(&inner_vector);
     MPI_Type_free(&outer_vector);
     return errs;
@@ -258,6 +259,7 @@ int optimizable_vector_of_basics_test(void)
         }
     }
 
+    free(buf);
     MPI_Type_free(&parent_type);
     return errs;
 }
@@ -347,6 +349,7 @@ int struct_of_basics_test(void)
         }
     }
 
+    free(buf);
     MPI_Type_free(&parent_type);
     return errs;
 }
diff --git a/test/mpi/datatype/simple-pack.c b/test/mpi/datatype/simple-pack.c
index 8483d73..96ddcff 100644
--- a/test/mpi/datatype/simple-pack.c
+++ b/test/mpi/datatype/simple-pack.c
@@ -174,6 +174,7 @@ int vector_of_vectors_test(void)
         }
     }
 
+    free(buf);
     MPI_Type_free(&inner_vector);
     MPI_Type_free(&outer_vector);
     return errs;
@@ -248,6 +249,7 @@ int optimizable_vector_of_basics_test(void)
         }
     }
 
+    free(buf);
     MPI_Type_free(&parent_type);
     return errs;
 }
diff --git a/test/mpi/datatype/structpack2.c b/test/mpi/datatype/structpack2.c
index ef6a411..74a511e 100644
--- a/test/mpi/datatype/structpack2.c
+++ b/test/mpi/datatype/structpack2.c
@@ -105,6 +105,7 @@ int main(int argc, char *argv[])
         }
     }
 
+    free(buffer);
     MPI_Type_free(&str);
     MPI_Type_free(&con);
     MTest_Finalize(errs);
diff --git a/test/mpi/datatype/transpose-pack.c b/test/mpi/datatype/transpose-pack.c
index 4429405..5689b99 100644
--- a/test/mpi/datatype/transpose-pack.c
+++ b/test/mpi/datatype/transpose-pack.c
@@ -84,6 +84,7 @@ int main(int argc, char *argv[])
     else {
         printf(" No Errors\n");
     }
+    free(buffer);
     MPI_Finalize();
     return 0;
 }
diff --git a/test/mpi/datatype/tresized.c b/test/mpi/datatype/tresized.c
index 079f3da..1c64d60 100644
--- a/test/mpi/datatype/tresized.c
+++ b/test/mpi/datatype/tresized.c
@@ -70,6 +70,7 @@ int main(int argc, char *argv[])
                 }
             }
         }
+        free(buf);
     }
 
     MPI_Type_free(&newtype);
diff --git a/test/mpi/datatype/tresized2.c b/test/mpi/datatype/tresized2.c
index d33bf17..7cbd3e3 100644
--- a/test/mpi/datatype/tresized2.c
+++ b/test/mpi/datatype/tresized2.c
@@ -74,6 +74,7 @@ int main(int argc, char *argv[])
                 }
             }
         }
+        free(buf);
     }
     MPI_Type_free(&newtype);
 
diff --git a/test/mpi/datatype/unpack.c b/test/mpi/datatype/unpack.c
index 5f0487f..5d9134f 100644
--- a/test/mpi/datatype/unpack.c
+++ b/test/mpi/datatype/unpack.c
@@ -99,6 +99,8 @@ int main(int argc, char **argv)
 
     MPI_Type_free(&mem_dtype);
 
+    free(mem_buf);
+    free(unpack_buf);
     MTest_Finalize(errs);
     MPI_Finalize();
 
diff --git a/test/mpi/errors/coll/bcastlength.c b/test/mpi/errors/coll/bcastlength.c
index 38343d3..e2713ce 100644
--- a/test/mpi/errors/coll/bcastlength.c
+++ b/test/mpi/errors/coll/bcastlength.c
@@ -22,6 +22,8 @@ int main(int argc, char *argv[])
     char str[MPI_MAX_ERROR_STRING + 1];
     int slen;
 
+    MTEST_VG_MEM_INIT(buf, 10 * sizeof(int));
+
     MTest_Init(&argc, &argv);
 
     MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
diff --git a/test/mpi/errors/coll/noalias2.c b/test/mpi/errors/coll/noalias2.c
index aac5c3c..5b99ce6 100644
--- a/test/mpi/errors/coll/noalias2.c
+++ b/test/mpi/errors/coll/noalias2.c
@@ -144,6 +144,8 @@ int main(int argc, char **argv)
         free(sdispls);
     if (rdispls)
         free(rdispls);
+    if (types)
+        free(types);
 
     if (rank == 0) {
         if (errs)
diff --git a/test/mpi/errors/coll/noalias3.c b/test/mpi/errors/coll/noalias3.c
index caaf924..6b8cf69 100644
--- a/test/mpi/errors/coll/noalias3.c
+++ b/test/mpi/errors/coll/noalias3.c
@@ -148,6 +148,8 @@ int main(int argc, char **argv)
         free(sdispls);
     if (rdispls)
         free(rdispls);
+    if (types)
+        free(types);
 
     if (rank == 0) {
         if (errs)
diff --git a/test/mpi/errors/comm/too_many_comms2.c b/test/mpi/errors/comm/too_many_comms2.c
index 40b8071..92e02f6 100644
--- a/test/mpi/errors/comm/too_many_comms2.c
+++ b/test/mpi/errors/comm/too_many_comms2.c
@@ -73,6 +73,7 @@ int main(int argc, char **argv)
         MPI_Comm_free(&comm_hdls[i]);
 
     free(comm_hdls);
+    free(ranks);
     MPI_Group_free(&world_group);
 
     MTest_Finalize(errors);
diff --git a/test/mpi/errors/comm/too_many_comms3.c b/test/mpi/errors/comm/too_many_comms3.c
index 614a72d..232897d 100644
--- a/test/mpi/errors/comm/too_many_comms3.c
+++ b/test/mpi/errors/comm/too_many_comms3.c
@@ -75,6 +75,7 @@ int main(int argc, char **argv)
         MPI_Comm_free(&comm_hdls[i]);
 
     free(comm_hdls);
+    free(ranks);
     MPI_Group_free(&world_group);
 
     MTest_Finalize(errors);
diff --git a/test/mpi/errors/cxx/io/fileerrretx.cxx b/test/mpi/errors/cxx/io/fileerrretx.cxx
index 455028e..c88cbb8 100644
--- a/test/mpi/errors/cxx/io/fileerrretx.cxx
+++ b/test/mpi/errors/cxx/io/fileerrretx.cxx
@@ -97,6 +97,7 @@ int main( int argc, char *argv[] )
 	}
     }
 
+    delete[] filename;
     MPI::Finalize();
 
     return 0;
diff --git a/test/mpi/errors/pt2pt/errinstatta.c b/test/mpi/errors/pt2pt/errinstatta.c
index ed79795..243f0a4 100644
--- a/test/mpi/errors/pt2pt/errinstatta.c
+++ b/test/mpi/errors/pt2pt/errinstatta.c
@@ -22,6 +22,9 @@ int main(int argc, char *argv[])
     int b1[20], b2[20], rank, size, src, dest, i, flag;
     int errval, errclass;
 
+    MTEST_VG_MEM_INIT(b1, 20 * sizeof(int));
+    MTEST_VG_MEM_INIT(b2, 20 * sizeof(int));
+
     MTest_Init(&argc, &argv);
 
     /* Create some receive requests.  tags 0-9 will succeed, tags 10-19
diff --git a/test/mpi/errors/pt2pt/errinstatts.c b/test/mpi/errors/pt2pt/errinstatts.c
index 79f1030..df51682 100644
--- a/test/mpi/errors/pt2pt/errinstatts.c
+++ b/test/mpi/errors/pt2pt/errinstatts.c
@@ -23,6 +23,9 @@ int main(int argc, char *argv[])
     int errval, errclass;
     int b1[20], b2[20], rank, size, src, dest, i, j;
 
+    MTEST_VG_MEM_INIT(b1, 20 * sizeof(int));
+    MTEST_VG_MEM_INIT(b2, 20 * sizeof(int));
+
     MTest_Init(&argc, &argv);
 
     /* Create some receive requests.  tags 0-9 will succeed, tags 10-19
diff --git a/test/mpi/errors/pt2pt/errinstatwa.c b/test/mpi/errors/pt2pt/errinstatwa.c
index 576ec1e..343a654 100644
--- a/test/mpi/errors/pt2pt/errinstatwa.c
+++ b/test/mpi/errors/pt2pt/errinstatwa.c
@@ -22,6 +22,9 @@ int main(int argc, char *argv[])
     int errval, errclass;
     int b1[20], b2[20], rank, size, src, dest, i;
 
+    MTEST_VG_MEM_INIT(b1, 20 * sizeof(int));
+    MTEST_VG_MEM_INIT(b2, 20 * sizeof(int));
+
     MTest_Init(&argc, &argv);
 
     /* Create some receive requests.  tags 0-9 will succeed, tags 10-19
diff --git a/test/mpi/errors/pt2pt/errinstatws.c b/test/mpi/errors/pt2pt/errinstatws.c
index a32c630..3b259c1 100644
--- a/test/mpi/errors/pt2pt/errinstatws.c
+++ b/test/mpi/errors/pt2pt/errinstatws.c
@@ -23,6 +23,9 @@ int main(int argc, char *argv[])
     int errval, errclass;
     int b1[20], b2[20], rank, size, src, dest, i, j;
 
+    MTEST_VG_MEM_INIT(b1, 20 * sizeof(int));
+    MTEST_VG_MEM_INIT(b2, 20 * sizeof(int));
+
     MTest_Init(&argc, &argv);
 
     /* Create some receive requests.  tags 0-9 will succeed, tags 10-19
diff --git a/test/mpi/errors/pt2pt/truncmsg1.c b/test/mpi/errors/pt2pt/truncmsg1.c
index 02f579f..f5aa345 100644
--- a/test/mpi/errors/pt2pt/truncmsg1.c
+++ b/test/mpi/errors/pt2pt/truncmsg1.c
@@ -37,6 +37,7 @@ int main(int argc, char *argv[])
     dest = size - 1;
 
     buf = (int *) malloc(LongLen * sizeof(int));
+    MTEST_VG_MEM_INIT(buf, LongLen * sizeof(int));
     if (!buf) {
         fprintf(stderr, "Unable to allocate communication buffer of size %d\n", LongLen);
         MPI_Abort(MPI_COMM_WORLD, 1);
diff --git a/test/mpi/errors/rma/win_sync_complete.c b/test/mpi/errors/rma/win_sync_complete.c
index ad52152..2684043 100644
--- a/test/mpi/errors/rma/win_sync_complete.c
+++ b/test/mpi/errors/rma/win_sync_complete.c
@@ -13,7 +13,7 @@ int main(int argc, char *argv[])
 {
     int rank;
     int errors = 0, all_errors = 0;
-    int buf;
+    int buf = 0;
     MPI_Win win;
 
     MPI_Init(&argc, &argv);
diff --git a/test/mpi/errors/rma/win_sync_free_at.c b/test/mpi/errors/rma/win_sync_free_at.c
index 971bac7..92124bb 100644
--- a/test/mpi/errors/rma/win_sync_free_at.c
+++ b/test/mpi/errors/rma/win_sync_free_at.c
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
 {
     int rank, nproc, i;
     int errors = 0, all_errors = 0;
-    int buf, *my_buf;
+    int buf = 0, *my_buf;
     MPI_Win win;
     MPI_Group world_group;
 
diff --git a/test/mpi/errors/rma/win_sync_free_pt.c b/test/mpi/errors/rma/win_sync_free_pt.c
index 80007ad..9d81b3d 100644
--- a/test/mpi/errors/rma/win_sync_free_pt.c
+++ b/test/mpi/errors/rma/win_sync_free_pt.c
@@ -13,7 +13,7 @@ int main(int argc, char *argv[])
 {
     int rank;
     int errors = 0, all_errors = 0;
-    int buf;
+    int buf = 0;
     MPI_Win win;
 
     MPI_Init(&argc, &argv);
diff --git a/test/mpi/errors/rma/win_sync_lock_at.c b/test/mpi/errors/rma/win_sync_lock_at.c
index 2740038..1e1511f 100644
--- a/test/mpi/errors/rma/win_sync_lock_at.c
+++ b/test/mpi/errors/rma/win_sync_lock_at.c
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
 {
     int rank, nproc, i;
     int errors = 0, all_errors = 0;
-    int buf, *my_buf;
+    int buf = 0, *my_buf;
     MPI_Win win;
     MPI_Group world_group;
 
diff --git a/test/mpi/errors/rma/win_sync_lock_fence.c b/test/mpi/errors/rma/win_sync_lock_fence.c
index 65ab791..ec7b63c 100644
--- a/test/mpi/errors/rma/win_sync_lock_fence.c
+++ b/test/mpi/errors/rma/win_sync_lock_fence.c
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
 {
     int rank, nproc;
     int errors = 0, all_errors = 0;
-    int buf, my_buf;
+    int buf = 0, my_buf;
     MPI_Win win;
 
     MPI_Init(&argc, &argv);
diff --git a/test/mpi/errors/rma/win_sync_lock_pt.c b/test/mpi/errors/rma/win_sync_lock_pt.c
index f982e88..6be8e8f 100644
--- a/test/mpi/errors/rma/win_sync_lock_pt.c
+++ b/test/mpi/errors/rma/win_sync_lock_pt.c
@@ -13,7 +13,7 @@ int main(int argc, char *argv[])
 {
     int rank;
     int errors = 0, all_errors = 0;
-    int buf;
+    int buf = 0;
     MPI_Win win;
 
     MPI_Init(&argc, &argv);
diff --git a/test/mpi/errors/rma/win_sync_nested.c b/test/mpi/errors/rma/win_sync_nested.c
index 48c2fff..3e3defd 100644
--- a/test/mpi/errors/rma/win_sync_nested.c
+++ b/test/mpi/errors/rma/win_sync_nested.c
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
 {
     int rank, nproc, i;
     int errors = 0, all_errors = 0;
-    int buf, *my_buf;
+    int buf = 0, *my_buf;
     MPI_Win win;
     MPI_Group world_group;
 
diff --git a/test/mpi/errors/rma/win_sync_op.c b/test/mpi/errors/rma/win_sync_op.c
index 69760f9..2048888 100644
--- a/test/mpi/errors/rma/win_sync_op.c
+++ b/test/mpi/errors/rma/win_sync_op.c
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
 {
     int rank, nproc;
     int errors = 0, all_errors = 0;
-    int buf, my_buf;
+    int buf = 0, my_buf;
     MPI_Win win;
 
     MPI_Init(&argc, &argv);
diff --git a/test/mpi/errors/rma/win_sync_unlock.c b/test/mpi/errors/rma/win_sync_unlock.c
index ec1ad30..ccef067 100644
--- a/test/mpi/errors/rma/win_sync_unlock.c
+++ b/test/mpi/errors/rma/win_sync_unlock.c
@@ -13,7 +13,7 @@ int main(int argc, char *argv[])
 {
     int rank;
     int errors = 0, all_errors = 0;
-    int buf;
+    int buf = 0;
     MPI_Win win;
 
     MPI_Init(&argc, &argv);
diff --git a/test/mpi/errors/rma/winerr.c b/test/mpi/errors/rma/winerr.c
index ed016e6..ad66486 100644
--- a/test/mpi/errors/rma/winerr.c
+++ b/test/mpi/errors/rma/winerr.c
@@ -41,6 +41,7 @@ int main(int argc, char *argv[])
     MPI_Comm comm;
     MPI_Errhandler newerr, olderr;
 
+    MTEST_VG_MEM_INIT(buf, 2 * sizeof(int));
 
     MTest_Init(&argc, &argv);
     comm = MPI_COMM_WORLD;
diff --git a/test/mpi/errors/rma/winerr2.c b/test/mpi/errors/rma/winerr2.c
index 6f0b585..e2f6700 100644
--- a/test/mpi/errors/rma/winerr2.c
+++ b/test/mpi/errors/rma/winerr2.c
@@ -64,6 +64,7 @@ int main(int argc, char *argv[])
     MPI_Comm comm;
     MPI_Errhandler newerr1, newerr2, olderr;
 
+    MTEST_VG_MEM_INIT(buf, 2 * sizeof(int));
 
     MTest_Init(&argc, &argv);
     comm = MPI_COMM_WORLD;
diff --git a/test/mpi/f77/coll/split_typef.f b/test/mpi/f77/coll/split_typef.f
index 27cfcd0..9b484b6 100644
--- a/test/mpi/f77/coll/split_typef.f
+++ b/test/mpi/f77/coll/split_typef.f
@@ -19,6 +19,7 @@ C
       call mtest_init( ierr )
 
       call mpi_comm_dup( MPI_COMM_WORLD, comm, ierr )
+      call mpi_comm_rank( comm, rank , ierr )
 
       call mpi_comm_split_type( comm, MPI_COMM_TYPE_SHARED, rank,
      &     MPI_INFO_NULL, newcomm, ierr )
diff --git a/test/mpi/group/groupcreate.c b/test/mpi/group/groupcreate.c
index ffbad0f..8079f55 100644
--- a/test/mpi/group/groupcreate.c
+++ b/test/mpi/group/groupcreate.c
@@ -79,6 +79,7 @@ implementation\n");
     }
 
     free(group_array);
+    free(ranks);
 
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/group/grouptest2.c b/test/mpi/group/grouptest2.c
index 00cb465..16bbaab 100644
--- a/test/mpi/group/grouptest2.c
+++ b/test/mpi/group/grouptest2.c
@@ -207,6 +207,8 @@ int main(int argc, char **argv)
             printf("Found %d errors in MPI Group routines\n", toterr);
     }
 
+    free(ranks);
+    free(ranks_out);
     MPI_Finalize();
     return toterr;
 }
diff --git a/test/mpi/impls/mpich/mpi_t/collparmt.c b/test/mpi/impls/mpich/mpi_t/collparmt.c
index f816c2e..6aec105 100644
--- a/test/mpi/impls/mpich/mpi_t/collparmt.c
+++ b/test/mpi/impls/mpich/mpi_t/collparmt.c
@@ -5,8 +5,10 @@
  */
 /* */
 #include <stdio.h>
+#include <string.h>
 #include "mpi.h"
 #include "mpitestconf.h"
+#include "mpitest.h"
 
 int main(int argc, char *argv[])
 {
@@ -23,6 +25,10 @@ int main(int argc, char *argv[])
     int newval;
     int errs = 0;
 
+    MTEST_VG_MEM_INIT(buf1, 400 * sizeof(char));
+    MTEST_VG_MEM_INIT(buf2, 400 * sizeof(char));
+    MTEST_VG_MEM_INIT(buf3, 400 * sizeof(char));
+
     MPI_Init(&argc, &argv);
     MPI_T_init_thread(MPI_THREAD_SINGLE, &provided);
 
diff --git a/test/mpi/include/mpitest.h b/test/mpi/include/mpitest.h
index 984c8c0..0932996 100644
--- a/test/mpi/include/mpitest.h
+++ b/test/mpi/include/mpitest.h
@@ -7,6 +7,7 @@
 #ifndef MPITEST_H_INCLUDED
 #define MPITEST_H_INCLUDED
 
+#include <string.h>
 #include "mpitestconf.h"
 
 /*
@@ -127,4 +128,10 @@ void MTestFreeWin(MPI_Win *);
     ((MTEST_MPI_VERSION == (major_) && MTEST_MPI_SUBVERSION >= (minor_)) ||   \
     (MTEST_MPI_VERSION > (major_)))
 
+/* useful for avoid valgrind warnings about padding bytes */
+#define MTEST_VG_MEM_INIT(addr_, size_) \
+do {                                    \
+    memset(addr_, 0, size_);            \
+} while (0)
+
 #endif
diff --git a/test/mpi/include/mpitestcxx.h b/test/mpi/include/mpitestcxx.h
index 6c1e878..1ea6d6c 100644
--- a/test/mpi/include/mpitestcxx.h
+++ b/test/mpi/include/mpitestcxx.h
@@ -10,6 +10,8 @@
 
 #ifndef MTEST_INCLUDED
 #define MTEST_INCLUDED
+
+#include <string.h>
 /*
  * Init and finalize test
  */
@@ -64,4 +66,10 @@ const char *MTestGetWinName(void);
 void MTestFreeWin(MPI::Win &);
 #endif
 
+/* useful for avoid valgrind warnings about padding bytes */
+#define MTEST_VG_MEM_INIT(addr_, size_) \
+do {                                    \
+    memset(addr_, 0, size_);            \
+} while (0)
+
 #endif
diff --git a/test/mpi/io/async.c b/test/mpi/io/async.c
index aa0141b..1bd75d3 100644
--- a/test/mpi/io/async.c
+++ b/test/mpi/io/async.c
@@ -59,6 +59,7 @@ int main(int argc, char **argv)
                 i++;
                 len = (int) strlen(*argv);
                 filename = (char *) malloc(len + 10);
+                MTEST_VG_MEM_INIT(filename, (len + 10) * sizeof(char));
                 strcpy(filename, *argv);
             }
             else if (strcmp(*argv, "-size") == 0) {
@@ -83,6 +84,7 @@ int main(int argc, char **argv)
             /* Use a default filename of testfile */
             len = 8;
             filename = (char *) malloc(len + 10);
+            MTEST_VG_MEM_INIT(filename, (len + 10) * sizeof(char));
             strcpy(filename, "testfile");
         }
         MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
diff --git a/test/mpi/io/async_any.c b/test/mpi/io/async_any.c
index 450894a..00b37e8 100644
--- a/test/mpi/io/async_any.c
+++ b/test/mpi/io/async_any.c
@@ -44,6 +44,7 @@ int main(int argc, char **argv)
             /* Use a default filename of testfile */
             len = 8;
             filename = (char *) malloc(len + 10);
+            memset(filename, 0, (len + 10) * sizeof(char));
             strcpy(filename, "testfile");
             /*
              * fprintf(stderr, "\n*#  Usage: async_any -fname filename\n\n");
@@ -54,6 +55,7 @@ int main(int argc, char **argv)
             argv++;
             len = (int) strlen(*argv);
             filename = (char *) malloc(len + 10);
+            MTEST_VG_MEM_INIT(filename, (len + 10) * sizeof(char));
             strcpy(filename, *argv);
         }
         MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
@@ -62,6 +64,7 @@ int main(int argc, char **argv)
     else {
         MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
         filename = (char *) malloc(len + 10);
+        MTEST_VG_MEM_INIT(filename, (len + 10) * sizeof(char));
         MPI_Bcast(filename, len + 10, MPI_CHAR, 0, MPI_COMM_WORLD);
     }
 
diff --git a/test/mpi/io/i_hindexed_io.c b/test/mpi/io/i_hindexed_io.c
index 9b99e04..d186123 100644
--- a/test/mpi/io/i_hindexed_io.c
+++ b/test/mpi/io/i_hindexed_io.c
@@ -110,5 +110,6 @@ int main(int argc, char **argv)
     MPI_Finalize();
 
     free(data);
+    free(verify);
     return 0;
 }
diff --git a/test/mpi/pt2pt/bsend1.c b/test/mpi/pt2pt/bsend1.c
index e813459..ea7538e 100644
--- a/test/mpi/pt2pt/bsend1.c
+++ b/test/mpi/pt2pt/bsend1.c
@@ -78,6 +78,8 @@ int main(int argc, char *argv[])
     /* We can't guarantee that messages arrive until the detach */
     MPI_Buffer_detach(&bbuf, &bsize);
 
+    free(buf);
+
     MTest_Finalize(errs);
 
     MPI_Finalize();
diff --git a/test/mpi/pt2pt/bsendfrag.c b/test/mpi/pt2pt/bsendfrag.c
index 768e496..55bf96c 100644
--- a/test/mpi/pt2pt/bsendfrag.c
+++ b/test/mpi/pt2pt/bsendfrag.c
@@ -83,6 +83,7 @@ int main(int argc, char *argv[])
         MPI_Barrier(comm);
         /* Detach waits until all messages received */
         MPI_Buffer_detach(&buf, &bsize);
+        free(buf);
     }
     else if (rank == dest) {
 
diff --git a/test/mpi/pt2pt/bsendpending.c b/test/mpi/pt2pt/bsendpending.c
index 7e42c20..77d7c16 100644
--- a/test/mpi/pt2pt/bsendpending.c
+++ b/test/mpi/pt2pt/bsendpending.c
@@ -83,6 +83,7 @@ int main(int argc, char *argv[])
                 fprintf(stderr, "Wrong buffer size returned\n");
                 errs++;
             }
+            free(buf);
         }
         else if (rank == dest) {
             double tstart;
diff --git a/test/mpi/pt2pt/eagerdt.c b/test/mpi/pt2pt/eagerdt.c
index dc3b1c5..529d490 100644
--- a/test/mpi/pt2pt/eagerdt.c
+++ b/test/mpi/pt2pt/eagerdt.c
@@ -51,6 +51,7 @@ int main(int argc, char *argv[])
             fprintf(stderr, "Unable to allocate buffer %d of size %ld\n", i, (long) extent);
             MPI_Abort(MPI_COMM_WORLD, 1);
         }
+        MTEST_VG_MEM_INIT(bufs[i], extent);
     }
     buf = (int *) malloc(10 * 30 * sizeof(int));
 
@@ -69,6 +70,10 @@ int main(int argc, char *argv[])
     }
 
     MPI_Type_free(&dtype);
+    for (i = 0; i < MAX_MSGS; i++) {
+        free(bufs[i]);
+    }
+    free(buf);
     MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/pt2pt/inactivereq.c b/test/mpi/pt2pt/inactivereq.c
index 6531b44..fd9e7d0 100644
--- a/test/mpi/pt2pt/inactivereq.c
+++ b/test/mpi/pt2pt/inactivereq.c
@@ -95,6 +95,7 @@ int main(int argc, char *argv[])
         MPI_Start(&r);
         MPI_Wait(&r, &s);
         MPI_Waitall(size, rr, MPI_STATUSES_IGNORE);
+        free(rr);
     }
     else {
         MPI_Start(&r);
diff --git a/test/mpi/pt2pt/isendirecv.c b/test/mpi/pt2pt/isendirecv.c
index 6980f92..39447f2 100644
--- a/test/mpi/pt2pt/isendirecv.c
+++ b/test/mpi/pt2pt/isendirecv.c
@@ -28,6 +28,7 @@ int main(int argc, char *argv[])
     reqs = (MPI_Request *) malloc(2 * nproc * sizeof(MPI_Request));
     in_buf = (float *) malloc(elems * nproc * sizeof(float));
     out_buf = (float *) malloc(elems * nproc * sizeof(float));
+    MTEST_VG_MEM_INIT(out_buf, elems * nproc * sizeof(float));
 
     for (i = 0; i < nproc; i++) {
         MPI_Irecv(&in_buf[elems * i], elems, MPI_FLOAT, i, 0, comm, &reqs[i]);
@@ -39,6 +40,9 @@ int main(int argc, char *argv[])
 
     MPI_Waitall(nproc * 2, reqs, MPI_STATUSES_IGNORE);
 
+    free(reqs);
+    free(in_buf);
+    free(out_buf);
     MTest_Finalize(errors);
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/pt2pt/rcancel.c b/test/mpi/pt2pt/rcancel.c
index 98122d5..07e3b66 100644
--- a/test/mpi/pt2pt/rcancel.c
+++ b/test/mpi/pt2pt/rcancel.c
@@ -78,6 +78,9 @@ int main(int argc, char *argv[])
             printf("Incorrectly cancelled Irecv[1]\n");
             fflush(stdout);
         }
+        for (i = 0; i < 4; i++) {
+            free(bufs[i]);
+        }
     }
 
     MTest_Finalize(errs);
diff --git a/test/mpi/pt2pt/rqfreeb.c b/test/mpi/pt2pt/rqfreeb.c
index 1c4f6a0..c6abf8a 100644
--- a/test/mpi/pt2pt/rqfreeb.c
+++ b/test/mpi/pt2pt/rqfreeb.c
@@ -80,6 +80,7 @@ int main(int argc, char *argv[])
 
         /* We can't guarantee that messages arrive until the detach */
         MPI_Buffer_detach(&bbuf, &bsize);
+        free(buf);
     }
 
     if (rank == dest) {
diff --git a/test/mpi/pt2pt/scancel2.c b/test/mpi/pt2pt/scancel2.c
index 2ecee0f..7492ecf 100644
--- a/test/mpi/pt2pt/scancel2.c
+++ b/test/mpi/pt2pt/scancel2.c
@@ -37,6 +37,7 @@ int main(int argc, char *argv[])
     for (cs = 0; cs < 4; cs++) {
         n = bufsizes[cs];
         buf = (char *) malloc(n);
+        MTEST_VG_MEM_INIT(buf, n);
         if (!buf) {
             fprintf(stderr, "Unable to allocate %d bytes\n", n);
             MPI_Abort(MPI_COMM_WORLD, 1);
diff --git a/test/mpi/pt2pt/sendrecv3.c b/test/mpi/pt2pt/sendrecv3.c
index 4cabf99..28deb55 100644
--- a/test/mpi/pt2pt/sendrecv3.c
+++ b/test/mpi/pt2pt/sendrecv3.c
@@ -50,6 +50,7 @@ int main(int argc, char *argv[])
                     fprintf(stderr, "Unable to allocate %d bytes\n", msgSize);
                     MPI_Abort(MPI_COMM_WORLD, 1);
                 }
+                MTEST_VG_MEM_INIT(buf[i], msgSize * sizeof(int));
             }
             partner = (rank + 1) % size;
 
diff --git a/test/mpi/rma/fetch_and_op.c b/test/mpi/rma/fetch_and_op.c
index 13ab278..bd10bb6 100644
--- a/test/mpi/rma/fetch_and_op.c
+++ b/test/mpi/rma/fetch_and_op.c
@@ -76,6 +76,8 @@ int main(int argc, char **argv)
 
     val_ptr = malloc(sizeof(TYPE_C) * nproc);
     res_ptr = malloc(sizeof(TYPE_C) * nproc);
+    MTEST_VG_MEM_INIT(val_ptr, sizeof(TYPE_C) * nproc);
+    MTEST_VG_MEM_INIT(res_ptr, sizeof(TYPE_C) * nproc);
 
     MPI_Win_create(val_ptr, sizeof(TYPE_C) * nproc, sizeof(TYPE_C), MPI_INFO_NULL, MPI_COMM_WORLD,
                    &win);
diff --git a/test/mpi/rma/linked_list_bench_lock_all.c b/test/mpi/rma/linked_list_bench_lock_all.c
index cf84edf..5e0dfa4 100644
--- a/test/mpi/rma/linked_list_bench_lock_all.c
+++ b/test/mpi/rma/linked_list_bench_lock_all.c
@@ -122,6 +122,8 @@ int main(int argc, char **argv)
         llist_ptr_t new_elem_ptr;
         int success = 0;
 
+        MTEST_VG_MEM_INIT(&new_elem_ptr, sizeof(llist_ptr_t));
+
         /* Create a new list element and register it with the window */
         new_elem_ptr.rank = procid;
         new_elem_ptr.disp = alloc_elem(procid, llist_win);
diff --git a/test/mpi/rma/linked_list_bench_lock_excl.c b/test/mpi/rma/linked_list_bench_lock_excl.c
index d2bd702..c52208e 100644
--- a/test/mpi/rma/linked_list_bench_lock_excl.c
+++ b/test/mpi/rma/linked_list_bench_lock_excl.c
@@ -118,6 +118,8 @@ int main(int argc, char **argv)
         llist_ptr_t new_elem_ptr;
         int success = 0;
 
+        MTEST_VG_MEM_INIT(&new_elem_ptr, sizeof(llist_ptr_t));
+
         /* Create a new list element and register it with the window */
         new_elem_ptr.rank = procid;
         new_elem_ptr.disp = alloc_elem(procid, llist_win);
diff --git a/test/mpi/rma/linked_list_bench_lock_shr.c b/test/mpi/rma/linked_list_bench_lock_shr.c
index 6973a22..9577b16 100644
--- a/test/mpi/rma/linked_list_bench_lock_shr.c
+++ b/test/mpi/rma/linked_list_bench_lock_shr.c
@@ -119,6 +119,8 @@ int main(int argc, char **argv)
         llist_ptr_t new_elem_ptr;
         int success = 0;
 
+        MTEST_VG_MEM_INIT(&new_elem_ptr, sizeof(llist_ptr_t));
+
         /* Create a new list element and register it with the window */
         new_elem_ptr.rank = procid;
         new_elem_ptr.disp = alloc_elem(procid, llist_win);
diff --git a/test/mpi/rma/lockcontention3.c b/test/mpi/rma/lockcontention3.c
index bc3fa79..8be8a50 100644
--- a/test/mpi/rma/lockcontention3.c
+++ b/test/mpi/rma/lockcontention3.c
@@ -163,6 +163,7 @@ int main(int argc, char *argv[])
     if (getbuf) {
         free(getbuf);
     }
+    free(srcbuf);
     MPI_Win_free(&win);
     MPI_Type_free(&vectype);
 
diff --git a/test/mpi/rma/manyget.c b/test/mpi/rma/manyget.c
index f498fcf..07b20af 100644
--- a/test/mpi/rma/manyget.c
+++ b/test/mpi/rma/manyget.c
@@ -12,6 +12,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <mpi.h>
+#include "mpitest.h"
 
 #define BUFSIZE (128*1024)
 
@@ -24,6 +25,7 @@ int main(int argc, char *argv[])
     MPI_Init(&argc, &argv);
 
     buf = malloc(BUFSIZE);
+    MTEST_VG_MEM_INIT(buf, BUFSIZE);
 
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
     MPI_Comm_size(MPI_COMM_WORLD, &size);
diff --git a/test/mpi/rma/strided_getacc_indexed_shared.c b/test/mpi/rma/strided_getacc_indexed_shared.c
index 7ed4a8d..6a36196 100644
--- a/test/mpi/rma/strided_getacc_indexed_shared.c
+++ b/test/mpi/rma/strided_getacc_indexed_shared.c
@@ -41,7 +41,7 @@ int main(int argc, char **argv)
     MPI_Comm_rank(MPI_COMM_WORLD, &rank_world);
     MPI_Comm_size(MPI_COMM_WORLD, &nranks_world);
 
-    MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, rank, MPI_INFO_NULL, &shr_comm);
+    MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, rank_world, MPI_INFO_NULL, &shr_comm);
 
     MPI_Comm_rank(shr_comm, &rank);
     MPI_Comm_size(shr_comm, &nranks);
diff --git a/test/mpi/rma/strided_putget_indexed_shared.c b/test/mpi/rma/strided_putget_indexed_shared.c
index 998debd..b6f2bfa 100644
--- a/test/mpi/rma/strided_putget_indexed_shared.c
+++ b/test/mpi/rma/strided_putget_indexed_shared.c
@@ -41,7 +41,7 @@ int main(int argc, char **argv)
     MPI_Comm_rank(MPI_COMM_WORLD, &rank_world);
     MPI_Comm_size(MPI_COMM_WORLD, &nranks_world);
 
-    MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, rank, MPI_INFO_NULL, &shr_comm);
+    MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, rank_world, MPI_INFO_NULL, &shr_comm);
 
     MPI_Comm_rank(shr_comm, &rank);
     MPI_Comm_size(shr_comm, &nranks);
diff --git a/test/mpi/rma/transpose7.c b/test/mpi/rma/transpose7.c
index 4b4f6a0..cd9e20b 100644
--- a/test/mpi/rma/transpose7.c
+++ b/test/mpi/rma/transpose7.c
@@ -90,6 +90,8 @@ int main(int argc, char *argv[])
             MPI_Win_fence(0, win);
         }
         MPI_Win_free(&win);
+        free(A_data);
+        free(A);
     }
     MPI_Comm_free(&CommDeuce);
     MTest_Finalize(errs);
diff --git a/test/mpi/spawn/multiple_ports.c b/test/mpi/spawn/multiple_ports.c
index c747fce..e5f1867 100644
--- a/test/mpi/spawn/multiple_ports.c
+++ b/test/mpi/spawn/multiple_ports.c
@@ -32,6 +32,9 @@ int main(int argc, char *argv[])
     int verbose = 0;
     int data = 0;
 
+    MTEST_VG_MEM_INIT(port1, MPI_MAX_PORT_NAME * sizeof(char));
+    MTEST_VG_MEM_INIT(port2, MPI_MAX_PORT_NAME * sizeof(char));
+
     if (getenv("MPITEST_VERBOSE")) {
         verbose = 1;
     }
diff --git a/test/mpi/spawn/multiple_ports2.c b/test/mpi/spawn/multiple_ports2.c
index b07f8dc..e88396c 100644
--- a/test/mpi/spawn/multiple_ports2.c
+++ b/test/mpi/spawn/multiple_ports2.c
@@ -38,6 +38,10 @@ int main(int argc, char *argv[])
     int verbose = 0;
     int data = 0;
 
+    MTEST_VG_MEM_INIT(port1, MPI_MAX_PORT_NAME * sizeof(char));
+    MTEST_VG_MEM_INIT(port2, MPI_MAX_PORT_NAME * sizeof(char));
+    MTEST_VG_MEM_INIT(port3, MPI_MAX_PORT_NAME * sizeof(char));
+
     if (getenv("MPITEST_VERBOSE")) {
         verbose = 1;
     }
diff --git a/test/mpi/spawn/selfconacc.c b/test/mpi/spawn/selfconacc.c
index 85d4e5c..a665a75 100644
--- a/test/mpi/spawn/selfconacc.c
+++ b/test/mpi/spawn/selfconacc.c
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "mpitest.h"
 
 void check_error(int, const char *);
 void check_error(int error, const char *fcname)
@@ -30,6 +31,8 @@ int main(int argc, char *argv[])
     MPI_Comm comm;
     int verbose = 0;
 
+    MTEST_VG_MEM_INIT(port, MPI_MAX_PORT_NAME * sizeof(char));
+
     if (getenv("MPITEST_VERBOSE")) {
         verbose = 1;
     }
diff --git a/test/mpi/spawn/spawnmanyarg.c b/test/mpi/spawn/spawnmanyarg.c
index 1547110..2275e91 100644
--- a/test/mpi/spawn/spawnmanyarg.c
+++ b/test/mpi/spawn/spawnmanyarg.c
@@ -114,6 +114,12 @@ int main(int argc, char *argv[])
         if (parentcomm == MPI_COMM_NULL) {
             MTest_Finalize(errs);
         }
+        /* free the argument vectors */
+        for (i = 0; i < MAX_ARGV; i++) {
+            free(inargv[i]);
+            free(outargv[i]);
+        }
+
     }
     else {
         MTest_Finalize(errs);
diff --git a/test/mpi/spawn/taskmaster.c b/test/mpi/spawn/taskmaster.c
index f5cffd7..6259900 100644
--- a/test/mpi/spawn/taskmaster.c
+++ b/test/mpi/spawn/taskmaster.c
@@ -158,6 +158,9 @@ int main(int argc, char *argv[])
 #ifdef USE_THREADS
     if (threads)
         free(threads);
+#else
+    if (child)
+        free(child);
 #endif
     MPI_Finalize();
 
diff --git a/test/mpi/threads/coll/allred.c b/test/mpi/threads/coll/allred.c
index 103a6e9..b8df28a 100644
--- a/test/mpi/threads/coll/allred.c
+++ b/test/mpi/threads/coll/allred.c
@@ -37,6 +37,8 @@ MTEST_THREAD_RETURN_TYPE test_iallred(void *arg)
     int tid = *(int *) arg;
     int buf[BUF_SIZE];
 
+    MTEST_VG_MEM_INIT(buf, BUF_SIZE * sizeof(int));
+
     if (tid == rank)
         MTestSleep(1);
     MPI_Allreduce(MPI_IN_PLACE, buf, BUF_SIZE, MPI_INT, MPI_BAND, comms[tid]);
diff --git a/test/mpi/threads/coll/iallred.c b/test/mpi/threads/coll/iallred.c
index 974d43b..a999142 100644
--- a/test/mpi/threads/coll/iallred.c
+++ b/test/mpi/threads/coll/iallred.c
@@ -37,6 +37,8 @@ MTEST_THREAD_RETURN_TYPE test_iallred(void *arg)
     int tid = *(int *) arg;
     int buf[BUF_SIZE];
 
+    MTEST_VG_MEM_INIT(buf, BUF_SIZE * sizeof(int));
+
     if (tid == rank)
         MTestSleep(1);
     MPI_Iallreduce(MPI_IN_PLACE, buf, BUF_SIZE, MPI_INT, MPI_BAND, comms[tid], &req);
diff --git a/test/mpi/threads/comm/ctxdup.c b/test/mpi/threads/comm/ctxdup.c
index c45c664..5870a94 100644
--- a/test/mpi/threads/comm/ctxdup.c
+++ b/test/mpi/threads/comm/ctxdup.c
@@ -92,6 +92,8 @@ int main(int argc, char *argv[])
     MPI_Ssend(buffer, 0, MPI_INT, rank, 1, MPI_COMM_WORLD);
     MPI_Recv(buffer, 0, MPI_INT, rank, 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
 
+    MTest_Join_threads();
+
     MPI_Comm_free(&comm4);
     MPI_Comm_free(&comm1);
     MPI_Comm_free(&comm2);
diff --git a/test/mpi/threads/comm/idup_nb.c b/test/mpi/threads/comm/idup_nb.c
index 28a7d3e..5b1046d 100644
--- a/test/mpi/threads/comm/idup_nb.c
+++ b/test/mpi/threads/comm/idup_nb.c
@@ -57,6 +57,7 @@ MTEST_THREAD_RETURN_TYPE test_intracomm(void *arg)
     MPI_Comm parentcomm = parentcomms[tid];
     MPI_Comm nbrcomm = nbrcomms[tid];
 
+    MPI_Comm_rank(parentcomm, &rank);
     for (i = 0; i < NUM_ITER; i++) {
         cnt = 0;
         if (*(int *) arg == rank)
@@ -70,7 +71,6 @@ MTEST_THREAD_RETURN_TYPE test_intracomm(void *arg)
             MPI_Comm_idup(parentcomm, &comms[j], &reqs[cnt++]);
 
         /* Issue an iscan on parent comm to overlap with the pending idups */
-        MPI_Comm_rank(parentcomm, &rank);
         MPI_Iscan(&rank, &ans[0], 1, MPI_INT, MPI_SUM, parentcomm, &reqs[cnt++]);
         expected[0] = rank * (rank + 1) / 2;
         /* Wait for the first child comm to be ready */
diff --git a/test/mpi/threads/pt2pt/ibsend.c b/test/mpi/threads/pt2pt/ibsend.c
index aa868be..208ba7a 100644
--- a/test/mpi/threads/pt2pt/ibsend.c
+++ b/test/mpi/threads/pt2pt/ibsend.c
@@ -50,6 +50,7 @@ void *receiver(void *ptr)
 void *sender_bsend(void *ptr)
 {
     char buffer[MSGSIZE];
+    MTEST_VG_MEM_INIT(buffer, MSGSIZE * sizeof(char));
     MPI_Bsend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD);
 
     return NULL;
@@ -59,6 +60,7 @@ void *sender_ibsend(void *ptr)
 {
     char buffer[MSGSIZE];
     MPI_Request req;
+    MTEST_VG_MEM_INIT(buffer, MSGSIZE * sizeof(char));
     MPI_Ibsend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD, &req);
     MPI_Wait(&req, MPI_STATUS_IGNORE);
 
@@ -69,6 +71,7 @@ void *sender_isend(void *ptr)
 {
     char buffer[MSGSIZE];
     MPI_Request req;
+    MTEST_VG_MEM_INIT(buffer, MSGSIZE * sizeof(char));
     MPI_Isend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD, &req);
     MPI_Wait(&req, MPI_STATUS_IGNORE);
 
@@ -78,6 +81,7 @@ void *sender_isend(void *ptr)
 void *sender_send(void *ptr)
 {
     char buffer[MSGSIZE];
+    MTEST_VG_MEM_INIT(buffer, MSGSIZE * sizeof(char));
     MPI_Send(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD);
 
     return NULL;
@@ -89,6 +93,7 @@ int main(int argc, char *argv[])
     int provided, i[2], k;
     char *buffer, *ptr_dt;
     buffer = (char *) malloc(BUFSIZE * sizeof(char));
+    MTEST_VG_MEM_INIT(buffer, BUFSIZE * sizeof(char));
     MPI_Status status;
     pthread_t receiver_thread, sender_thread[NUMSENDS];
     pthread_attr_t attr;
diff --git a/test/mpi/threads/pt2pt/multisend2.c b/test/mpi/threads/pt2pt/multisend2.c
index 4035504..ee51a93 100644
--- a/test/mpi/threads/pt2pt/multisend2.c
+++ b/test/mpi/threads/pt2pt/multisend2.c
@@ -31,6 +31,7 @@ MTEST_THREAD_RETURN_TYPE run_test_send(void *arg)
 
     for (cnt = 1; cnt < MAX_CNT; cnt = 2 * cnt) {
         buf = (int *) malloc(cnt * sizeof(int));
+        MTEST_VG_MEM_INIT(buf, cnt * sizeof(int));
 
         /* Wait for all senders to be ready */
         MTest_thread_barrier(nthreads);
@@ -55,6 +56,7 @@ void run_test_recv(void)
 
     for (cnt = 1; cnt < MAX_CNT; cnt = 2 * cnt) {
         buf = (int *) malloc(cnt * sizeof(int));
+        MTEST_VG_MEM_INIT(buf, cnt * sizeof(int));
         t = MPI_Wtime();
         for (j = 0; j < MAX_LOOP; j++)
             MPI_Recv(buf, cnt, MPI_INT, 0, cnt, MPI_COMM_WORLD, &status);
diff --git a/test/mpi/threads/pt2pt/multisend3.c b/test/mpi/threads/pt2pt/multisend3.c
index fb307d7..f9a43be 100644
--- a/test/mpi/threads/pt2pt/multisend3.c
+++ b/test/mpi/threads/pt2pt/multisend3.c
@@ -38,6 +38,7 @@ MTEST_THREAD_RETURN_TYPE run_test_send(void *arg)
     /* Create the buf just once to avoid finding races in malloc instead
      * of the MPI library */
     buf = (int *) malloc(MAX_CNT * sizeof(int));
+    MTEST_VG_MEM_INIT(buf, MAX_CNT * sizeof(int));
     MTestPrintfMsg(1, "buf address %p (size %d)\n", buf, MAX_CNT * sizeof(int));
     MPI_Comm_size(MPI_COMM_WORLD, &wsize);
     if (wsize >= MAX_NTHREAD)
@@ -83,6 +84,7 @@ void run_test_recv(void)
 
     for (cnt = 1; cnt < MAX_CNT; cnt = 2 * cnt) {
         buf = (int *) malloc(cnt * sizeof(int));
+        MTEST_VG_MEM_INIT(buf, cnt * sizeof(int));
         t = MPI_Wtime();
         for (j = 0; j < MAX_LOOP; j++)
             MPI_Recv(buf, cnt, MPI_INT, 0, cnt, MPI_COMM_WORLD, &status);
diff --git a/test/mpi/threads/pt2pt/multisend4.c b/test/mpi/threads/pt2pt/multisend4.c
index b65bf4f..8a359d2 100644
--- a/test/mpi/threads/pt2pt/multisend4.c
+++ b/test/mpi/threads/pt2pt/multisend4.c
@@ -46,6 +46,7 @@ MTEST_THREAD_RETURN_TYPE run_test_sendrecv(void *arg)
 
     for (cnt = 1; cnt < MAX_CNT; cnt = 2 * cnt) {
         buf = (int *) malloc(2 * cnt * sizeof(int));
+        MTEST_VG_MEM_INIT(buf, 2 * cnt * sizeof(int));
 
         /* Wait for all senders to be ready */
         MTest_thread_barrier(nthreads);
diff --git a/test/mpi/threads/pt2pt/threaded_sr.c b/test/mpi/threads/pt2pt/threaded_sr.c
index 277037d..cafe1e0 100644
--- a/test/mpi/threads/pt2pt/threaded_sr.c
+++ b/test/mpi/threads/pt2pt/threaded_sr.c
@@ -35,6 +35,7 @@ MTEST_THREAD_RETURN_TYPE send_thread(void *p)
     int rank;
 
     buffer = malloc(sizeof(char) * MSG_SIZE);
+    MTEST_VG_MEM_INIT(buffer, MSG_SIZE * sizeof(char));
     if (buffer == NULL) {
         printf("malloc failed to allocate %d bytes for the send buffer.\n", MSG_SIZE);
         fflush(stdout);
@@ -58,6 +59,7 @@ MTEST_THREAD_RETURN_TYPE send_thread(void *p)
     else {
         sendok = 1;
     }
+    free(buffer);
     return (MTEST_THREAD_RETURN_TYPE) (long) err;
 }
 
@@ -100,6 +102,7 @@ int main(int argc, char *argv[])
     MTestSleep(3);
 
     buffer = malloc(sizeof(char) * MSG_SIZE);
+    MTEST_VG_MEM_INIT(buffer, MSG_SIZE * sizeof(char));
     if (buffer == NULL) {
         printf("malloc failed to allocate %d bytes for the recv buffer.\n", MSG_SIZE);
         fflush(stdout);
@@ -125,6 +128,8 @@ int main(int argc, char *argv[])
         errs++;
     }
 
+    MTest_Join_threads();
+    free(buffer);
     MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/topo/distgraph1.c b/test/mpi/topo/distgraph1.c
index 4c0fe49..20c6671 100644
--- a/test/mpi/topo/distgraph1.c
+++ b/test/mpi/topo/distgraph1.c
@@ -213,6 +213,10 @@ static int verify_comm(MPI_Comm comm)
     if (dupcomm != MPI_COMM_NULL)
         MPI_Comm_free(&dupcomm);
 
+    free(sources);
+    free(sweights);
+    free(destinations);
+    free(dweights);
     return local_errs;
 }
 
@@ -563,6 +567,11 @@ int main(int argc, char *argv[])
     for (i = 0; i < size; i++)
         free(layout[i]);
     free(layout);
+    free(sources);
+    free(sweights);
+    free(destinations);
+    free(dweights);
+    free(degrees);
 #endif
 
     MTest_Finalize(errs);
diff --git a/test/mpi/util/dtypes.c b/test/mpi/util/dtypes.c
index 7c7082a..57d295e 100644
--- a/test/mpi/util/dtypes.c
+++ b/test/mpi/util/dtypes.c
@@ -379,6 +379,7 @@ void MTestDatatype2Free(MPI_Datatype * types, void **inbufs, void **outbufs,
         if (i >= nbasic_types)
             MPI_Type_free(types + i);
     }
+    free(types);
     free(inbufs);
     free(outbufs);
     free(counts);

-----------------------------------------------------------------------

Summary of changes:
 src/mpi/rma/alloc_mem.c                           |    1 +
 src/mpi/romio/adio/common/malloc.c                |    1 +
 src/mpi/spawn/comm_join.c                         |    2 +
 src/mpi/topo/topoutil.c                           |    2 +
 src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.c |   28 ++---------------
 src/mpid/ch3/include/mpid_rma_issue.h             |    5 +++
 src/mpid/ch3/src/ch3u_win_fns.c                   |    1 +
 src/mpl/include/mpl_valgrind.h                    |    9 ++++++
 test/mpi/coll/bcastzerotype.c                     |    2 +
 test/mpi/coll/nonblocking.c                       |    2 +
 test/mpi/coll/opland.c                            |    1 +
 test/mpi/coll/oplor.c                             |    1 +
 test/mpi/coll/oplxor.c                            |    1 +
 test/mpi/coll/opmax.c                             |    1 +
 test/mpi/coll/opmin.c                             |    1 +
 test/mpi/coll/opminloc.c                          |    1 +
 test/mpi/coll/opprod.c                            |    2 +
 test/mpi/coll/opsum.c                             |    2 +
 test/mpi/coll/redscat.c                           |    3 ++
 test/mpi/coll/redscat2.c                          |    1 +
 test/mpi/coll/scatter3.c                          |    2 +
 test/mpi/coll/scattern.c                          |    2 +
 test/mpi/comm/comm_create_group.c                 |    1 +
 test/mpi/comm/comm_group_rand.c                   |    2 +
 test/mpi/comm/comm_idup_isend.c                   |    1 +
 test/mpi/cxx/coll/arcomplex.cxx                   |    1 +
 test/mpi/cxx/comm/commname2.cxx                   |    2 +-
 test/mpi/cxx/io/filemiscx.cxx                     |    2 +
 test/mpi/cxx/pt2pt/bsend1cxx.cxx                  |    2 +-
 test/mpi/cxx/pt2pt/sendrecvx.cxx                  |   32 +++++++++++----------
 test/mpi/cxx/spawn/selfconaccx.cxx                |    2 +
 test/mpi/datatype/getpartelm.c                    |    2 +
 test/mpi/datatype/large_type.c                    |    2 +
 test/mpi/datatype/large_vec.c                     |    1 +
 test/mpi/datatype/simple-pack-external.c          |    3 ++
 test/mpi/datatype/simple-pack.c                   |    2 +
 test/mpi/datatype/structpack2.c                   |    1 +
 test/mpi/datatype/transpose-pack.c                |    1 +
 test/mpi/datatype/tresized.c                      |    1 +
 test/mpi/datatype/tresized2.c                     |    1 +
 test/mpi/datatype/unpack.c                        |    2 +
 test/mpi/errors/coll/bcastlength.c                |    2 +
 test/mpi/errors/coll/noalias2.c                   |    2 +
 test/mpi/errors/coll/noalias3.c                   |    2 +
 test/mpi/errors/comm/too_many_comms2.c            |    1 +
 test/mpi/errors/comm/too_many_comms3.c            |    1 +
 test/mpi/errors/cxx/io/fileerrretx.cxx            |    1 +
 test/mpi/errors/pt2pt/errinstatta.c               |    3 ++
 test/mpi/errors/pt2pt/errinstatts.c               |    3 ++
 test/mpi/errors/pt2pt/errinstatwa.c               |    3 ++
 test/mpi/errors/pt2pt/errinstatws.c               |    3 ++
 test/mpi/errors/pt2pt/truncmsg1.c                 |    1 +
 test/mpi/errors/rma/win_sync_complete.c           |    2 +-
 test/mpi/errors/rma/win_sync_free_at.c            |    2 +-
 test/mpi/errors/rma/win_sync_free_pt.c            |    2 +-
 test/mpi/errors/rma/win_sync_lock_at.c            |    2 +-
 test/mpi/errors/rma/win_sync_lock_fence.c         |    2 +-
 test/mpi/errors/rma/win_sync_lock_pt.c            |    2 +-
 test/mpi/errors/rma/win_sync_nested.c             |    2 +-
 test/mpi/errors/rma/win_sync_op.c                 |    2 +-
 test/mpi/errors/rma/win_sync_unlock.c             |    2 +-
 test/mpi/errors/rma/winerr.c                      |    1 +
 test/mpi/errors/rma/winerr2.c                     |    1 +
 test/mpi/f77/coll/split_typef.f                   |    1 +
 test/mpi/group/groupcreate.c                      |    1 +
 test/mpi/group/grouptest2.c                       |    2 +
 test/mpi/impls/mpich/mpi_t/collparmt.c            |    6 ++++
 test/mpi/include/mpitest.h                        |    7 ++++
 test/mpi/include/mpitestcxx.h                     |    8 +++++
 test/mpi/io/async.c                               |    2 +
 test/mpi/io/async_any.c                           |    3 ++
 test/mpi/io/i_hindexed_io.c                       |    1 +
 test/mpi/pt2pt/bsend1.c                           |    2 +
 test/mpi/pt2pt/bsendfrag.c                        |    1 +
 test/mpi/pt2pt/bsendpending.c                     |    1 +
 test/mpi/pt2pt/eagerdt.c                          |    5 +++
 test/mpi/pt2pt/inactivereq.c                      |    1 +
 test/mpi/pt2pt/isendirecv.c                       |    4 ++
 test/mpi/pt2pt/rcancel.c                          |    3 ++
 test/mpi/pt2pt/rqfreeb.c                          |    1 +
 test/mpi/pt2pt/scancel2.c                         |    1 +
 test/mpi/pt2pt/sendrecv3.c                        |    1 +
 test/mpi/rma/fetch_and_op.c                       |    2 +
 test/mpi/rma/linked_list_bench_lock_all.c         |    2 +
 test/mpi/rma/linked_list_bench_lock_excl.c        |    2 +
 test/mpi/rma/linked_list_bench_lock_shr.c         |    2 +
 test/mpi/rma/lockcontention3.c                    |    1 +
 test/mpi/rma/manyget.c                            |    2 +
 test/mpi/rma/strided_getacc_indexed_shared.c      |    2 +-
 test/mpi/rma/strided_putget_indexed_shared.c      |    2 +-
 test/mpi/rma/transpose7.c                         |    2 +
 test/mpi/spawn/multiple_ports.c                   |    3 ++
 test/mpi/spawn/multiple_ports2.c                  |    4 ++
 test/mpi/spawn/selfconacc.c                       |    3 ++
 test/mpi/spawn/spawnmanyarg.c                     |    6 ++++
 test/mpi/spawn/taskmaster.c                       |    3 ++
 test/mpi/threads/coll/allred.c                    |    2 +
 test/mpi/threads/coll/iallred.c                   |    2 +
 test/mpi/threads/comm/ctxdup.c                    |    2 +
 test/mpi/threads/comm/idup_nb.c                   |    2 +-
 test/mpi/threads/pt2pt/ibsend.c                   |    5 +++
 test/mpi/threads/pt2pt/multisend2.c               |    2 +
 test/mpi/threads/pt2pt/multisend3.c               |    2 +
 test/mpi/threads/pt2pt/multisend4.c               |    1 +
 test/mpi/threads/pt2pt/threaded_sr.c              |    5 +++
 test/mpi/topo/distgraph1.c                        |    9 ++++++
 test/mpi/util/dtypes.c                            |    1 +
 107 files changed, 241 insertions(+), 53 deletions(-)


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list