Index: /branches/jch-memory/psLib/src/sys/psMemory.c
===================================================================
--- /branches/jch-memory/psLib/src/sys/psMemory.c	(revision 10887)
+++ /branches/jch-memory/psLib/src/sys/psMemory.c	(revision 10888)
@@ -8,6 +8,6 @@
 *  @author Robert Lupton, Princeton University
 *
-*  @version $Revision: 1.88.2.3 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-01-03 04:30:32 $
+*  @version $Revision: 1.88.2.4 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-01-03 04:46:32 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -25,5 +25,4 @@
 #include "psError.h"
 #include "psAssert.h"
-#include "psAbort.h"
 #include "psLogMsg.h"
 #include "psBitSet.h"
@@ -48,4 +47,13 @@
 }
 
+// psAbort() calls functions that call psAlloc() so it is *UNSAFE* to use it
+// from within the memory subsystem.  Previous implementations tried to do
+// this and would deadlock while trying to allocate memory.
+#define PS_MEM_ABORT(name, ...) \
+fprintf(stderr, "Memory Management Error. This error can not be logged.\n") ;\
+fprintf(stderr, __VA_ARGS__);\
+fprintf(stderr, "\n");\
+abort();
+
 static psS32 checkMemBlock(const psMemBlock* m, const char *funcName);
 static psMemBlock* lastMemBlockAllocated = NULL;
@@ -107,5 +115,5 @@
 
     if (lineno > 0) {
-        psAbort(__func__, "Detected a problem in the memory system at %s:%d", file, lineno);
+        PS_MEM_ABORT(__func__, "Detected a problem in the memory system at %s:%d", file, lineno);
     }
 }
@@ -299,5 +307,5 @@
                 // release the lock on the memblock list
                 MUTEX_UNLOCK(&memBlockListMutex);
-                psAbort(__func__, "Detected memory corruption");
+                PS_MEM_ABORT(__func__, "Detected memory corruption");
                 return nbad;
             }
@@ -338,5 +346,5 @@
             ptr = memExhaustedCallback(size);
             if (ptr == NULL) {
-                psAbort(__func__, "Failed to allocate %zd bytes at %s:%d", size, file, lineno);
+                PS_MEM_ABORT(__func__, "Failed to allocate %zd bytes at %s:%d", size, file, lineno);
             }
         }
@@ -396,6 +404,6 @@
     if (checkMemBlock(ptr, __func__) != 0) {
         memProblemCallback(ptr, file, lineno);
-        psAbort(file, "Realloc detected a memory corruption (id %lu @ %s:%d).",
-                (unsigned long)ptr->id, ptr->file, ptr->lineno);
+        PS_MEM_ABORT(file, "Realloc detected a memory corruption (id %lu @ %s:%d).",
+                     (unsigned long)ptr->id, ptr->file, ptr->lineno);
     }
 
@@ -414,5 +422,5 @@
         ptr = memExhaustedCallback(size);
         if (ptr == NULL) {
-            psAbort(__func__, "Failed to reallocate %zd bytes at %s:%d", size, file, lineno);
+            PS_MEM_ABORT(__func__, "Failed to reallocate %zd bytes at %s:%d", size, file, lineno);
         }
     }
@@ -454,11 +462,11 @@
         psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
 
-        psAbort(__func__,_("Block %lu, allocated at %s:%d, freed multiple times at %s:%d."),
-                (unsigned long)ptr->id, ptr->file, ptr->lineno, filename, lineno);
+        PS_MEM_ABORT(__func__,_("Block %lu, allocated at %s:%d, freed multiple times at %s:%d."),
+                     (unsigned long)ptr->id, ptr->file, ptr->lineno, filename, lineno);
     }
 
     if (checkMemBlock(ptr, __func__) != 0) {
         memProblemCallback(ptr, filename, lineno);
-        psAbort(__func__,"Memory Corruption Detected.");
+        PS_MEM_ABORT(__func__,"Memory Corruption Detected.");
     }
 
