[mpich2-commits] r7971 - mpich2/trunk/src/util/mem

goodell at mcs.anl.gov goodell at mcs.anl.gov
Tue Feb 15 15:58:52 CST 2011


Author: goodell
Date: 2011-02-15 15:58:52 -0600 (Tue, 15 Feb 2011)
New Revision: 7971

Modified:
   mpich2/trunk/src/util/mem/handlemem.c
Log:
fill freed handlemem object with 0xec when --enable-g=mem is used

This helps to trigger segfaults, assertions, and other errors in the case
that an MPI object is prematurely freed by the user or library.  This was
already well-handled for regular malloc/free and when running under valgrind,
but this commit helps for non-valgrind situations as well.

Reviewed by buntinas at .

Modified: mpich2/trunk/src/util/mem/handlemem.c
===================================================================
--- mpich2/trunk/src/util/mem/handlemem.c	2011-02-15 20:44:27 UTC (rev 7970)
+++ mpich2/trunk/src/util/mem/handlemem.c	2011-02-15 21:58:52 UTC (rev 7971)
@@ -440,6 +440,16 @@
 
     MPIU_THREAD_MPI_OBJ_FINALIZE(obj);
 
+#ifdef USE_MEMORY_TRACING
+    {
+        /* set the object memory to an invalid value (0xec), except for the handle field */
+        int tmp_handle;
+        tmp_handle = obj->handle;
+        memset(obj, 0xec, objmem->size);
+        obj->handle = tmp_handle;
+    }
+#endif
+
     MPL_VG_MEMPOOL_FREE(objmem, obj);
     /* MEMPOOL_FREE marks the object NOACCESS, so we have to make the
      * MPIU_Handle_common area that is used for internal book keeping



More information about the mpich2-commits mailing list