From dima@tejblum.dnttm.rssi.ru  Sat Aug  9 09:10:00 1997
Received: from main.hq.cti.ru (main.hq.cti.ru [194.67.85.27])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id JAA29865
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 9 Aug 1997 09:09:53 -0700 (PDT)
Received: (from uucp@localhost)
	by main.hq.cti.ru (8.8.5/8.8.5) with UUCP id UAA19139
	for FreeBSD-gnats-submit@freebsd.org; Sat, 9 Aug 1997 20:09:48 +0400 (MSD)
Received: (from dima@localhost)
	by tejblum.dnttm.rssi.ru (8.8.7/8.8.5) id UAA18642;
	Sat, 9 Aug 1997 20:07:55 +0400 (MSD)
Message-Id: <199708091607.UAA18642@tejblum.dnttm.rssi.ru>
Date: Sat, 9 Aug 1997 20:07:55 +0400 (MSD)
From: Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru>
Reply-To: dima@tejblum.dnttm.rssi.ru
To: FreeBSD-gnats-submit@freebsd.org
Subject: make in free(): warning: chunk is already free
X-Send-Pr-Version: 3.2

>Number:         4254
>Category:       bin
>Synopsis:       make in free(): warning: chunk is already free
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    steve
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug  9 09:10:01 PDT 1997
>Closed-Date:    Sun Apr 26 02:45:00 PDT 1998
>Last-Modified:  Sun Apr 26 02:45:16 PDT 1998
>Originator:     Dmitrij Tejblum
>Release:        FreeBSD 3.0-CURRENT-src-cur-2995 i386
>Organization:
>Environment:


>Description:

When all transformation rules to or from a suffix disappeared, make tries 
to free the suffix. I think, it is a very strange idea. (Or, maybe, it is a 
POSIX requirement?) And it is done incorrectly. Apparently, it even don't 
update the list of known suffixes (but it is an other bug).

>How-To-Repeat:

Try following Makefile:

-----------------------cut here----------
.SUFFIXES: .xxx

.xxx.c:

aaaa: bbbbb 
------------------------cut here---------

>Fix:
	
--- suff.c.00	Wed Mar 12 12:44:53 1997
+++ suff.c	Sat Aug  9 19:26:04 1997
@@ -160,7 +160,6 @@
 static int SuffSuffHasNameP __P((ClientData, ClientData));
 static int SuffSuffIsPrefix __P((ClientData, ClientData));
 static int SuffGNHasNameP __P((ClientData, ClientData));
-static void SuffUnRef __P((ClientData, ClientData));
 static void SuffFree __P((ClientData));
 static void SuffInsert __P((Lst, Suff *));
 static void SuffRemove __P((Lst, Suff *));
@@ -327,20 +326,6 @@
 
  	    /*********** Maintenance Functions ************/
 
-static void
-SuffUnRef(lp, sp)
-    ClientData lp;
-    ClientData sp;
-{
-    Lst l = (Lst) lp;
-
-    LstNode ln = Lst_Member(l, sp);
-    if (ln != NILLNODE) {
-	Lst_Remove(l, ln);
-	((Suff *) sp)->refCount--;
-    }
-}
-
 /*-
  *-----------------------------------------------------------------------
  * SuffFree  --
@@ -383,8 +368,7 @@
  *	None
  *
  * Side Effects:
- *	The reference count for the suffix is decremented and the
- *	suffix is possibly freed
+ *	The reference count for the suffix is decremented
  *-----------------------------------------------------------------------
  */
 static void
@@ -392,9 +376,11 @@
     Lst l;
     Suff *s;
 {
-    SuffUnRef((ClientData) l, (ClientData) s);
-    if (s->refCount == 0)
-	SuffFree((ClientData) s);
+    LstNode ln = Lst_Member(l, (ClientData)s);
+    if (ln != NILLNODE) {
+	Lst_Remove(l, ln);
+	s->refCount--;
+    }
 }
 
 /*-

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->steve 
Responsible-Changed-By: wosch 
Responsible-Changed-When: Sun Sep 14 11:19:24 PDT 1997 
Responsible-Changed-Why:  
make is Steve Passe area. 
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Sun Apr 26 02:45:00 PDT 1998 
State-Changed-Why:  
committed, thanks! 
>Unformatted:
