[mpich2-commits] r4060 - in mpich2/trunk/src: include mpi/attr mpi/comm mpi/init mpi/rma mpid/common/datatype

goodell at mcs.anl.gov goodell at mcs.anl.gov
Fri Mar 13 17:49:14 CDT 2009


Author: goodell
Date: 2009-03-13 17:49:14 -0500 (Fri, 13 Mar 2009)
New Revision: 4060

Modified:
   mpich2/trunk/src/include/mpiimpl.h
   mpich2/trunk/src/mpi/attr/attr.h
   mpich2/trunk/src/mpi/attr/attrutil.c
   mpich2/trunk/src/mpi/comm/commutil.c
   mpich2/trunk/src/mpi/init/finalize.c
   mpich2/trunk/src/mpi/rma/win_free.c
   mpich2/trunk/src/mpid/common/datatype/mpid_datatype.h
Log:
Attribute bugfix (fixes ticket #455).

We were not zeroing the attribute list for an object at
{comm,win,type}_free time.

Reviewed by balaji at .

Modified: mpich2/trunk/src/include/mpiimpl.h
===================================================================
--- mpich2/trunk/src/include/mpiimpl.h	2009-03-13 18:00:32 UTC (rev 4059)
+++ mpich2/trunk/src/include/mpiimpl.h	2009-03-13 22:49:14 UTC (rev 4060)
@@ -2071,7 +2071,7 @@
 
     /* Attribute dup functions.  Here for lazy initialization */
     int (*attr_dup)( int, MPID_Attribute *, MPID_Attribute ** );
-    int (*attr_free)( int, MPID_Attribute * );
+    int (*attr_free)( int, MPID_Attribute ** );
     /* There is no win_attr_dup function because there can be no MPI_Win_dup
        function */
     /* Routine to get the messages corresponding to dynamically created

Modified: mpich2/trunk/src/mpi/attr/attr.h
===================================================================
--- mpich2/trunk/src/mpi/attr/attr.h	2009-03-13 18:00:32 UTC (rev 4059)
+++ mpich2/trunk/src/mpi/attr/attr.h	2009-03-13 22:49:14 UTC (rev 4060)
@@ -12,7 +12,7 @@
 extern MPID_Keyval MPID_Keyval_direct[];
 
 extern int MPIR_Attr_dup_list( int, MPID_Attribute *, MPID_Attribute ** );
-extern int MPIR_Attr_delete_list( int, MPID_Attribute * );
+extern int MPIR_Attr_delete_list( int, MPID_Attribute ** );
 extern MPID_Attribute *MPID_Attr_alloc(void);
 extern void MPID_Attr_free(MPID_Attribute *attr_ptr);
 extern int MPIR_Call_attr_delete( int, MPID_Attribute * );

Modified: mpich2/trunk/src/mpi/attr/attrutil.c
===================================================================
--- mpich2/trunk/src/mpi/attr/attrutil.c	2009-03-13 18:00:32 UTC (rev 4059)
+++ mpich2/trunk/src/mpi/attr/attrutil.c	2009-03-13 22:49:14 UTC (rev 4060)
@@ -223,12 +223,13 @@
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
 /* Routine to delete an attribute list */
-int MPIR_Attr_delete_list( int handle, MPID_Attribute *attr )
+int MPIR_Attr_delete_list( int handle, MPID_Attribute **attr )
 {
     MPID_Attribute *p, *new_p;
     int mpi_errno = MPI_SUCCESS;
+    MPID_Comm *comm_ptr;
 
-    p = attr;
+    p = *attr;
     while (p) {
 	/* delete the attribute by first executing the delete routine, if any,
 	   determine the the next attribute, and recover the attributes 
@@ -269,6 +270,17 @@
 	
 	p = new_p;
     }
+
+    /* We must zero out the attribute list pointer or we could attempt to use it
+       later.  This normally can't happen because the communicator usually
+       disappears after a call to MPI_Comm_free.  But if the attribute keyval
+       has an associated delete function that returns an error then we don't
+       actually free the communicator despite having freed all the attributes
+       associated with the communicator.
+
+       This function is also used for Win and Type objects, but the idea is the
+       same in those cases as well. */
+    *attr = NULL;
     return mpi_errno;
 }
 

Modified: mpich2/trunk/src/mpi/comm/commutil.c
===================================================================
--- mpich2/trunk/src/mpi/comm/commutil.c	2009-03-13 18:00:32 UTC (rev 4059)
+++ mpich2/trunk/src/mpi/comm/commutil.c	2009-03-13 22:49:14 UTC (rev 4060)
@@ -987,7 +987,7 @@
                the attr_free code requires a valid communicator */ 
 	    MPIU_Object_add_ref( comm_ptr ); 
 	    mpi_errno = MPIR_Process.attr_free( comm_ptr->handle, 
-						comm_ptr->attributes );
+						&comm_ptr->attributes );
 	    /* Release the temporary reference added before the call to 
                attr_free */ 
 	    MPIU_Object_release_ref( comm_ptr, &inuse); 

Modified: mpich2/trunk/src/mpi/init/finalize.c
===================================================================
--- mpich2/trunk/src/mpi/init/finalize.c	2009-03-13 18:00:32 UTC (rev 4059)
+++ mpich2/trunk/src/mpi/init/finalize.c	2009-03-13 22:49:14 UTC (rev 4060)
@@ -142,12 +142,12 @@
        in MPID_Finalize) */
     if (MPIR_Process.attr_free && MPIR_Process.comm_self->attributes) {
         mpi_errno = MPIR_Process.attr_free( MPI_COMM_SELF,
-					    MPIR_Process.comm_self->attributes);
+					    &MPIR_Process.comm_self->attributes);
 	MPIR_Process.comm_self->attributes = 0;
     }
     if (MPIR_Process.attr_free && MPIR_Process.comm_world->attributes) {
         mpi_errno = MPIR_Process.attr_free( MPI_COMM_WORLD, 
-                                         MPIR_Process.comm_world->attributes);
+                                            &MPIR_Process.comm_world->attributes);
 	MPIR_Process.comm_world->attributes = 0;
     }
 

Modified: mpich2/trunk/src/mpi/rma/win_free.c
===================================================================
--- mpich2/trunk/src/mpi/rma/win_free.c	2009-03-13 18:00:32 UTC (rev 4059)
+++ mpich2/trunk/src/mpi/rma/win_free.c	2009-03-13 22:49:14 UTC (rev 4060)
@@ -93,7 +93,7 @@
     if (MPIR_Process.attr_free && win_ptr->attributes)
     {
 	mpi_errno = MPIR_Process.attr_free( win_ptr->handle, 
-					    win_ptr->attributes );
+					    &win_ptr->attributes );
     }
     /*
      * If the user attribute free function returns an error, 

Modified: mpich2/trunk/src/mpid/common/datatype/mpid_datatype.h
===================================================================
--- mpich2/trunk/src/mpid/common/datatype/mpid_datatype.h	2009-03-13 18:00:32 UTC (rev 4059)
+++ mpich2/trunk/src/mpid/common/datatype/mpid_datatype.h	2009-03-13 22:49:14 UTC (rev 4060)
@@ -59,7 +59,7 @@
         int lmpi_errno = MPI_SUCCESS;					    \
 	if (MPIR_Process.attr_free && datatype_ptr->attributes) {	    \
 	    lmpi_errno = MPIR_Process.attr_free( datatype_ptr->handle,	    \
-						datatype_ptr->attributes ); \
+						 &datatype_ptr->attributes ); \
 	}								    \
  	/* LEAVE THIS COMMENTED OUT UNTIL WE HAVE SOME USE FOR THE FREE_FN  \
 	if (datatype_ptr->free_fn) {					    \



More information about the mpich2-commits mailing list