79d3be498f1a8e4971e2001bcc8c0d481b6bba06
galt
  Tue Aug 9 16:36:40 2011 -0700
fix problem with interaction between memTracker (which is currently used only by gfServer) and errabort code which allocates perThreadVars off of the heap.  The fix just makes it use errabort stuff before starting memTracker.
diff --git src/gfServer/gfServer.c src/gfServer/gfServer.c
index cf2544a..7d668bc 100644
--- src/gfServer/gfServer.c
+++ src/gfServer/gfServer.c
@@ -395,91 +395,96 @@
 
 static jmp_buf gfRecover;
 static char *ripCord = NULL;	/* A little memory to give back to system
                                  * during error recovery. */
 
 static void gfAbort()
 /* Abort query. */
 {
 freez(&ripCord);
 longjmp(gfRecover, -1);
 }
 
 static void errorSafeSetup()
 /* Start up error safe stuff. */
 {
+pushAbortHandler(gfAbort); // must come before memTracker
 memTrackerStart();
-pushAbortHandler(gfAbort);
 ripCord = needMem(64*1024); /* Memory for error recovery. memTrackerEnd frees */
 }
 
+static void errorSafeCleanup()
+/* Clean up and report problem. */
+{
+memTrackerEnd();
+popAbortHandler();  // must come after memTracker
+}
+
 static void errorSafeCleanupMess(int connectionHandle, char *message)
 /* Clean up and report problem. */
 {
-popAbortHandler();
+errorSafeCleanup();
 logError("Recovering from error via longjmp");
 netSendString(connectionHandle, message);
 }
 
 static void errorSafeQuery(boolean doTrans, boolean queryIsProt, 
 	struct dnaSeq *seq, struct genoFind *gf, struct genoFind *transGf[2][3], 
 	int connectionHandle, char *buf)
 /* Wrap error handling code around index query. */
 {
 int status;
 errorSafeSetup();
 status = setjmp(gfRecover);
 if (status == 0)    /* Always true except after long jump. */
     {
     if (doTrans)
        {
        if (queryIsProt)
 	    transQuery(transGf, seq, connectionHandle, buf);
        else
 	    transTransQuery(transGf, seq, 
 		connectionHandle, buf);
        }
     else
 	dnaQuery(gf, seq, connectionHandle, buf);
-    popAbortHandler();
+    errorSafeCleanup();
     }
 else    /* They long jumped here because of an error. */
     {
     errorSafeCleanupMess(connectionHandle, 
     	"Error: gfServer out of memory. Try reducing size of query.");
     }
-memTrackerEnd();
 }
 
 static void errorSafePcr(struct genoFind *gf, char *fPrimer, char *rPrimer, 
 	int maxDistance, int connectionHandle)
 /* Wrap error handling around pcr index query. */
 {
 int status;
 errorSafeSetup();
 status = setjmp(gfRecover);
 if (status == 0)    /* Always true except after long jump. */
     {
     pcrQuery(gf, fPrimer, rPrimer, maxDistance, connectionHandle);
-    popAbortHandler();
+    errorSafeCleanup();
     }
 else    /* They long jumped here because of an error. */
     {
     errorSafeCleanupMess(connectionHandle, 
     	"Error: gfServer out of memory."); 
     }
-memTrackerEnd();
 }
 
 boolean badPcrPrimerSeq(char *s)
 /* Return TRUE if have a character we can't handle in sequence. */
 {
 unsigned char c;
 while ((c = *s++) != 0)
     {
     if (ntVal[c] < 0)
         return TRUE;
     }
 return FALSE;
 }
 
 void startServer(char *hostName, char *portName, int fileCount,