f1a4a262044ed35475efe87e454788e49f567534
galt
  Thu May 9 16:23:43 2019 -0700
fixing out of memory problems on htmlCheck

diff --git src/lib/memalloc.c src/lib/memalloc.c
index 2011c27..89aa3ff 100644
--- src/lib/memalloc.c
+++ src/lib/memalloc.c
@@ -281,32 +281,38 @@
  * return memory block. */
 {
 pthread_mutex_lock( &carefulMutex );
 struct carefulMemBlock *cmb;
 char *pEndCookie;
 size_t newAlloced = size + carefulAlloced;
 size_t aliSize;
 
 if (newAlloced > carefulMaxToAlloc)
     {
     char maxAlloc[32];
     char allocRequest[32];
     sprintLongWithCommas(maxAlloc, (long long)carefulMaxToAlloc);
     sprintLongWithCommas(allocRequest, (long long)newAlloced);
     pthread_mutex_unlock( &carefulMutex );
-    errAbort("carefulAlloc: Allocated too much memory - more than %s bytes (%s)",
+
+    // Avoid out-of-memory issues by exiting immediately.
+    char errMsg[1024];
+    safef(errMsg, sizeof errMsg, "carefulAlloc: Allocated too much memory - more than %s bytes (%s). Exiting.\n",
 	maxAlloc, allocRequest);
+    write(STDERR_FILENO, errMsg, strlen(errMsg)); 
+    exit(1);   // out of memory is a serious problem, exit immediately, but allow atexit cleanup.
+    // avoid errAbort which allocates memory causing problems.
     }
 carefulAlloced = newAlloced;
 aliSize = ((size + sizeof(*cmb) + 4 + carefulAlignAdd)&carefulAlignMask);
 cmb = carefulParent->alloc(aliSize);
 cmb->size = size;
 cmb->startCookie = cmbStartCookie;
 pEndCookie = (char *)(cmb+1);
 pEndCookie += size;
 memcpy(pEndCookie, cmbEndCookie, sizeof(cmbEndCookie));
 dlAddHead(cmbAllocedList, (struct dlNode *)cmb);
 pthread_mutex_unlock( &carefulMutex );
 return (void *)(cmb+1);
 }
 
 static void carefulFree(void *vpt)