dep-colon-bug-cross-file.mk revision 1.4 1 1.4 rillig # $NetBSD: dep-colon-bug-cross-file.mk,v 1.4 2020/09/27 09:53:41 rillig Exp $
2 1.4 rillig #
3 1.4 rillig # Until 2020-09-25, the very last dependency group of a top-level makefile
4 1.4 rillig # was not finished properly. This made it possible to add further commands
5 1.4 rillig # to that target.
6 1.4 rillig #
7 1.4 rillig # In pass 1, there is a dependency group at the bottom of the file.
8 1.4 rillig # This dependency group is not finished properly. Finishing the dependency
9 1.4 rillig # group would add the OP_HAS_COMMANDS flag to the "all" target, thereby
10 1.4 rillig # preventing any commands from being added later.
11 1.4 rillig #
12 1.4 rillig # After the file has been parsed completely, it is parsed again in pass 2.
13 1.4 rillig # In this pass, another command is added to the "current dependency group",
14 1.4 rillig # which was still the one from pass 1, which means it was possible to later
15 1.4 rillig # add commands to an existing target, even across file boundaries.
16 1.4 rillig #
17 1.4 rillig # Oops, even worse. Running this test in a make from 2020-09-25 or earlier
18 1.4 rillig # on NetBSD 8.0 x86_64 with MALLOC_OPTIONS=JA produces this or a similar
19 1.4 rillig # output:
20 1.4 rillig #
21 1.4 rillig # make: cannot open ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ.
22 1.4 rillig #
23 1.4 rillig # The 'Z' means access to already freed memory; see jemalloc(3). The cause
24 1.4 rillig # for this is that in MainParseArgs, the command line arguments were not
25 1.4 rillig # properly copied before storing them in global variables.
26 1.4 rillig
27 1.4 rillig PASS?= 1
28 1.4 rillig
29 1.4 rillig .if ${PASS} == 2
30 1.4 rillig all:
31 1.4 rillig : pass 2
32 1.4 rillig .endif
33 1.4 rillig
34 1.4 rillig .if ${PASS} == 1
35 1.4 rillig
36 1.4 rillig PASS= 2
37 1.4 rillig .MAKEFLAGS: -f ${.PARSEDIR:q}/${.PARSEFILE:q}
38 1.4 rillig
39 1.4 rillig all:
40 1.4 rillig : pass 1
41 1.4 rillig .endif
42