Module Name: src
Committed By: rillig
Date: Sun Dec 6 20:55:30 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: opt-file.mk
Log Message:
make(1): document undefined behavior from 2014
Earlier versions of make didn't know the -v option to print the expanded
value of a variable. To make the test runnable by older makes as well,
switch to -V instead, which has been available much longer.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-file.mk
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/unit-tests/opt-file.mk
diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.6 src/usr.bin/make/unit-tests/opt-file.mk:1.7
--- src/usr.bin/make/unit-tests/opt-file.mk:1.6 Sun Dec 6 20:33:44 2020
+++ src/usr.bin/make/unit-tests/opt-file.mk Sun Dec 6 20:55:30 2020
@@ -1,4 +1,4 @@
-# $NetBSD: opt-file.mk,v 1.6 2020/12/06 20:33:44 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.7 2020/12/06 20:55:30 rillig Exp $
#
# Tests for the -f command line option.
@@ -12,9 +12,28 @@ all: file-containing-null-byte
#
# In the unlikely case where a file ends in a backslash instead of a newline,
# that backslash is trimmed. See ParseGetLine.
+#
+# make-2014.01.01.00.00.00 invoked undefined behavior, reading text from
+# outside of the file buffer.
+#
+# printf '%s' 'VAR=value\' \
+# | MALLOC_OPTIONS=JA make-2014.01.01.00.00.00 -r -f - -V VAR -dA 2>&1 \
+# | less
+#
+# The debug output shows how make happily uses freshly allocated memory (the
+# <A5>) and already freed memory ('Z').
+#
+# ParseReadLine (1): 'VAR=value\<A5><A5><A5><A5><A5><A5>'
+# Global:VAR = value\<A5><A5><A5><A5><A5><A5>value\<A5><A5><A5><A5><A5><A5>
+# ParseReadLine (2): 'alue\<A5><A5><A5><A5><A5><A5>'
+# ParseDoDependency(alue\<A5><A5><A5><A5><A5><A5>)
+# make-2014.01.01.00.00.00: "(stdin)" line 2: Need an operator
+# ParseReadLine (3): '<A5><A5><A5>ZZZZZZZZZZZZZZZZ'
+# ParseDoDependency(<A5><A5><A5>ZZZZZZZZZZZZZZZZ)
+#
file-ending-in-backslash: .PHONY
@printf '%s' 'VAR=value\' \
- | ${MAKE} -r -f - -v VAR
+ | ${MAKE} -r -f - -V VAR
# If a file contains null bytes, the rest of the line is skipped, and parsing
# continues in the next line. Throughout the history of make, the behavior
@@ -61,7 +80,7 @@ file-ending-in-backslash: .PHONY
file-containing-null-byte: .PHONY
@printf '%s\n' 'VAR=value' 'VAR2=VALUE2' \
| tr 'l' '\0' \
- | ${MAKE} -r -f - -v VAR -v VAR2
+ | ${MAKE} -r -f - -V VAR -V VAR2
all:
: Making ${.TARGET}