Date: Fri, 10 Jan 2003 15:39:21 -0800 From: Marcel Moolenaar <marcel@xcllnt.net> To: arch@FreeBSD.org Cc: ru@FreeBSD.org Subject: Infinite loop in make(1) Message-ID: <20030110233921.GA1381@athlon.pn.xcllnt.net>
next in thread | raw e-mail | index | archive | help
Gang, During release building we hit upon an infinite loop in make(1). This was cause by a substitution of which the LHS and RHS were both empty and the substitution was to be applied globally. For example (from ports/devel/m6811-gcc/Makefile): CFLAGS := ${CFLAGS:S/${_CPUCFLAGS}//g} If ${_CPUCFLAGS} is empty, the expansion obviously yields S///g. This causes make(1) to enter an infinite loop. Below a patch to prevent the infinite loop by forcing non-global substitution. This still allows S/^/foo/ and S/$/bar/ and even S///, but avoids the danger zone. Is this correct? \begin{patch} Index: var.c =================================================================== RCS file: /home/ncvs/src/usr.bin/make/var.c,v retrieving revision 1.40 diff -u -r1.40 var.c --- var.c 8 Nov 2002 16:59:11 -0000 1.40 +++ var.c 10 Jan 2003 23:30:58 -0000 @@ -1349,6 +1349,17 @@ cp++; } + /* + * Replacing the empty string for something else when + * done globally causes an infinite loop. The only + * meaningful substitution of the empty string would + * be those anchored by '^' or '$'. Thus, we can + * safely turn the substitution into a non-global one + * if the LHS is the empty string. + */ + if (pattern.leftLen == 0) + pattern.flags &= ~VAR_SUB_GLOBAL; + termc = *cp; newStr = VarModify(str, VarSubstitute, (void *)&pattern); \end{patch} -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030110233921.GA1381>