Hi,

as the subject says, I'm able to detect a memory leak in ksh93u+ 2012-02-29.
Therefore I've backported my patch for 2012-02-14 to 2012-02-29 and with
this change the problem is gone (see first attachment).

The script causing the leak is in the second attachent.  The script accepts
a loop count like

   leak2.sh 400
   leak2.sh 4000

and without leaks the memory consumption is equal for both 400 and 4000
loops used in the script.

Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c
@@ -508,24 +508,26 @@ static void put_cdpath(register Namval_t
 static void put_ifs(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
 {
 	register struct ifs *ip = (struct ifs*)fp;
+	Namfun_t	    *xp;
 	ip->ifsnp = 0;
-	if(!val)
-	{
-		fp = nv_stack(np, NIL(Namfun_t*));
-		if(fp && !fp->nofree)
-		{
-			free((void*)fp);
-			fp = 0;
-		}
-	}
-	if(val != np->nvalue.cp)
-		nv_putv(np, val, flags, fp);
-	if(!val)
+	if(val)
 	{
-		if(fp)
-			fp->next = np->nvfun;
-		np->nvfun = fp;
+		if(val != np->nvalue.cp)
+			nv_putv(np, val, flags, fp);
+		return;
 	}
+	if((xp = nv_stack(np, NIL(Namfun_t*))) != fp)
+		sfprintf(sfstderr, "BUG in %s:%s(%d) xp(%p) != fp(%p)\n",
+			 __FILE__, __FUNCTION__, __LINE__, xp, fp);
+	if(fp && !fp->nofree)
+	{
+		free((void*)fp);
+		fp = NIL(Namfun_t*);
+	}
+	nv_putv(np, NIL(char*), flags, fp);
+	if(fp)
+		fp->next = np->nvfun;
+	np->nvfun = fp;
 }
 
 /*

Attachment: leak2.sh
Description: application/shellscript

_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to