[mpich2-commits] r4028 - mpich2/trunk/test/mpi/attr

goodell at mcs.anl.gov goodell at mcs.anl.gov
Thu Mar 12 12:42:59 CDT 2009


Author: goodell
Date: 2009-03-12 12:42:59 -0500 (Thu, 12 Mar 2009)
New Revision: 4028

Added:
   mpich2/trunk/test/mpi/attr/keyval_double_free.c
Modified:
   mpich2/trunk/test/mpi/attr/Makefile.sm
   mpich2/trunk/test/mpi/attr/testlist
Log:
Add a new test for double-freeing attriute keyvals.

No reviewer.

Modified: mpich2/trunk/test/mpi/attr/Makefile.sm
===================================================================
--- mpich2/trunk/test/mpi/attr/Makefile.sm	2009-03-12 17:42:57 UTC (rev 4027)
+++ mpich2/trunk/test/mpi/attr/Makefile.sm	2009-03-12 17:42:59 UTC (rev 4028)
@@ -18,6 +18,7 @@
 fkeyval_SOURCES = fkeyval.c
 fkeyvalcomm_SOURCES = fkeyvalcomm.c
 fkeyvaltype_SOURCES = fkeyvaltype.c
+keyval_double_free_SOURCES = keyval_double_free.c
 
 ../util/mtest.o:
 	(cd ../util && $(MAKE) mtest.o)

Added: mpich2/trunk/test/mpi/attr/keyval_double_free.c
===================================================================
--- mpich2/trunk/test/mpi/attr/keyval_double_free.c	                        (rev 0)
+++ mpich2/trunk/test/mpi/attr/keyval_double_free.c	2009-03-12 17:42:59 UTC (rev 4028)
@@ -0,0 +1,37 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ *
+ *  (C) 2009 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+#include <mpi.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/* tests multiple invocations of Keyval_free on the same keyval */
+
+int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra) {
+    MPI_Keyval_free(&keyval);
+}
+
+int main (int argc, char **argv)
+{
+    MPI_Comm duped;
+    int keyval = MPI_KEYVAL_INVALID;
+    int keyval_copy = MPI_KEYVAL_INVALID;
+    MPI_Init(&argc, &argv);
+    MPI_Comm_dup(MPI_COMM_SELF, &duped);
+
+    MPI_Keyval_create(MPI_NULL_COPY_FN, delete_fn,  &keyval, NULL);
+    keyval_copy = keyval;
+
+    MPI_Attr_put(MPI_COMM_SELF, keyval, NULL);
+    MPI_Attr_put(duped, keyval, NULL);
+
+    MPI_Comm_free(&duped);         /* first MPI_Keyval_free */
+    MPI_Keyval_free(&keyval);      /* second MPI_Keyval_free */
+    MPI_Keyval_free(&keyval_copy); /* third MPI_Keyval_free */
+    printf(" No Errors\n");
+    MPI_Finalize();                /* fourth MPI_Keyval_free */
+    return 0;
+}

Modified: mpich2/trunk/test/mpi/attr/testlist
===================================================================
--- mpich2/trunk/test/mpi/attr/testlist	2009-03-12 17:42:57 UTC (rev 4027)
+++ mpich2/trunk/test/mpi/attr/testlist	2009-03-12 17:42:59 UTC (rev 4028)
@@ -14,3 +14,4 @@
 fkeyval 1
 fkeyvalcomm 1
 fkeyvaltype 1
+keyval_double_free 1



More information about the mpich2-commits mailing list