Module Name:    src
Committed By:   rillig
Date:           Mon Aug 31 05:56:02 UTC 2020

Modified Files:
        src/usr.bin/make: lst.c suff.c

Log Message:
make(1): fix unbalanced Lst_Open/Lst_Close in SuffFindCmds

This bug had been there since the initial import of make, on 1993-03-21.
It just never broke the build because of the missing assertion.

https://mail-index.netbsd.org/tech-toolchain/2020/08/30/msg003847.html

The error message "cd: can't cd to include" that I got when I first
applied the fix was unrelated.  It was caused by an extra directory
"include" in src/tools/compat that didn't belong there.  With that
directory removed, running "./build.sh -j8 tools" succeeds as expected.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/usr.bin/make/lst.c
cvs rdiff -u -r1.140 -r1.141 src/usr.bin/make/suff.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.59 src/usr.bin/make/lst.c:1.60
--- src/usr.bin/make/lst.c:1.59	Sun Aug 30 21:20:06 2020
+++ src/usr.bin/make/lst.c	Mon Aug 31 05:56:02 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.59 2020/08/30 21:20:06 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.60 2020/08/31 05:56:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.59 2020/08/30 21:20:06 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.60 2020/08/31 05:56:02 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.59 2020/08/30 21:20:06 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.60 2020/08/31 05:56:02 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -542,12 +542,7 @@ void
 Lst_Open(Lst list)
 {
     assert(list != NULL);
-
-    /* XXX: This assertion fails for NetBSD's "build.sh -j1 tools", somewhere
-     * between "dependall ===> compat" and "dependall ===> binstall".
-     * Building without the "-j1" succeeds though. */
-    if (DEBUG(LINT) && list->isOpen)
-	Parse_Error(PARSE_WARNING, "Internal inconsistency: list opened twice");
+    assert(!list->isOpen);
 
     list->isOpen = TRUE;
     list->lastAccess = LstIsEmpty(list) ? Head : Unknown;

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.140 src/usr.bin/make/suff.c:1.141
--- src/usr.bin/make/suff.c:1.140	Sun Aug 30 18:26:41 2020
+++ src/usr.bin/make/suff.c	Mon Aug 31 05:56:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.140 2020/08/30 18:26:41 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.141 2020/08/31 05:56:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.140 2020/08/30 18:26:41 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.141 2020/08/31 05:56:02 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)suff.c	8.4 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: suff.c,v 1.140 2020/08/30 18:26:41 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.141 2020/08/31 05:56:02 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -230,7 +230,6 @@ static int SuffRebuildGraph(void *, void
 static int SuffScanTargets(void *, void *);
 static int SuffAddSrc(void *, void *);
 static void SuffAddLevel(Lst, Src *);
-static Src *SuffFindCmds(Src *, Lst);
 static void SuffExpandChildren(LstNode, GNode *);
 static void SuffExpandWildcards(LstNode, GNode *);
 static Boolean SuffApplyTransform(GNode *, GNode *, Suff *, Suff *);
@@ -1232,6 +1231,7 @@ SuffFindCmds(Src *targ, Lst slst)
 #endif
     Lst_Append(slst, ret);
     SUFF_DEBUG1("\tusing existing source %s\n", s->name);
+    Lst_Close(t->children);
     return ret;
 }
 

Reply via email to