Sat Aug 22 19:53:22 2020 UTC ()
make(1): replace segmentation fault with failed assertion

To reproduce: ./make -r -C unit-tests -f sh-dots.mk -j1

Without -j1, the test succeeds.


(rillig)
diff -r1.124 -r1.125 src/usr.bin/make/compat.c

cvs diff -r1.124 -r1.125 src/usr.bin/make/compat.c (expand / switch to unified diff)

--- src/usr.bin/make/compat.c 2020/08/22 15:43:32 1.124
+++ src/usr.bin/make/compat.c 2020/08/22 19:53:22 1.125
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: compat.c,v 1.124 2020/08/22 15:43:32 rillig Exp $ */ 1/* $NetBSD: compat.c,v 1.125 2020/08/22 19:53:22 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -60,55 +60,56 @@ @@ -60,55 +60,56 @@
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE. 69 * SUCH DAMAGE.
70 */ 70 */
71 71
72#ifndef MAKE_NATIVE 72#ifndef MAKE_NATIVE
73static char rcsid[] = "$NetBSD: compat.c,v 1.124 2020/08/22 15:43:32 rillig Exp $"; 73static char rcsid[] = "$NetBSD: compat.c,v 1.125 2020/08/22 19:53:22 rillig Exp $";
74#else 74#else
75#include <sys/cdefs.h> 75#include <sys/cdefs.h>
76#ifndef lint 76#ifndef lint
77#if 0 77#if 0
78static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; 78static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
79#else 79#else
80__RCSID("$NetBSD: compat.c,v 1.124 2020/08/22 15:43:32 rillig Exp $"); 80__RCSID("$NetBSD: compat.c,v 1.125 2020/08/22 19:53:22 rillig Exp $");
81#endif 81#endif
82#endif /* not lint */ 82#endif /* not lint */
83#endif 83#endif
84 84
85/*- 85/*-
86 * compat.c -- 86 * compat.c --
87 * The routines in this file implement the full-compatibility 87 * The routines in this file implement the full-compatibility
88 * mode of PMake. Most of the special functionality of PMake 88 * mode of PMake. Most of the special functionality of PMake
89 * is available in this mode. Things not supported: 89 * is available in this mode. Things not supported:
90 * - different shells. 90 * - different shells.
91 * - friendly variable substitution. 91 * - friendly variable substitution.
92 * 92 *
93 * Interface: 93 * Interface:
94 * Compat_Run Initialize things for this module and recreate 94 * Compat_Run Initialize things for this module and recreate
95 * thems as need creatin' 95 * thems as need creatin'
96 */ 96 */
97 97
98#include <sys/types.h> 98#include <sys/types.h>
99#include <sys/stat.h> 99#include <sys/stat.h>
100#include <sys/wait.h> 100#include <sys/wait.h>
101 101
 102#include <assert.h>
102#include <ctype.h> 103#include <ctype.h>
103#include <errno.h> 104#include <errno.h>
104#include <signal.h> 105#include <signal.h>
105#include <stdio.h> 106#include <stdio.h>
106 107
107#include "make.h" 108#include "make.h"
108#include "hash.h" 109#include "hash.h"
109#include "dir.h" 110#include "dir.h"
110#include "job.h" 111#include "job.h"
111#include "metachar.h" 112#include "metachar.h"
112#include "pathnames.h" 113#include "pathnames.h"
113 114
114 115
@@ -240,26 +241,27 @@ CompatRunCommand(void *cmdp, void *gnp) @@ -240,26 +241,27 @@ CompatRunCommand(void *cmdp, void *gnp)
240 * execvp to choke and die horribly. Besides, how can we execute a null 241 * execvp to choke and die horribly. Besides, how can we execute a null
241 * command? In any case, we warn the user that the command expanded to 242 * command? In any case, we warn the user that the command expanded to
242 * nothing (is this the right thing to do?). 243 * nothing (is this the right thing to do?).
243 */ 244 */
244 245
245 if (*cmdStart == '\0') { 246 if (*cmdStart == '\0') {
246 free(cmdStart); 247 free(cmdStart);
247 return 0; 248 return 0;
248 } 249 }
249 cmd = cmdStart; 250 cmd = cmdStart;
250 Lst_ReplaceS(cmdNode, cmdStart); 251 Lst_ReplaceS(cmdNode, cmdStart);
251 252
252 if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) { 253 if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
 254 assert(ENDNode != NULL);
253 Lst_AppendS(ENDNode->commands, cmdStart); 255 Lst_AppendS(ENDNode->commands, cmdStart);
254 return 0; 256 return 0;
255 } 257 }
256 if (strcmp(cmdStart, "...") == 0) { 258 if (strcmp(cmdStart, "...") == 0) {
257 gn->type |= OP_SAVE_CMDS; 259 gn->type |= OP_SAVE_CMDS;
258 return 0; 260 return 0;
259 } 261 }
260 262
261 while ((*cmd == '@') || (*cmd == '-') || (*cmd == '+')) { 263 while ((*cmd == '@') || (*cmd == '-') || (*cmd == '+')) {
262 switch (*cmd) { 264 switch (*cmd) {
263 case '@': 265 case '@':
264 silent = DEBUG(LOUD) ? FALSE : TRUE; 266 silent = DEBUG(LOUD) ? FALSE : TRUE;
265 break; 267 break;