1*148ee845SSimon J. Gerraty# $NetBSD: dep-colon-bug-cross-file.mk,v 1.5 2023/06/01 20:56:35 rillig Exp $ 2956e45f6SSimon J. Gerraty# 3956e45f6SSimon J. Gerraty# Until 2020-09-25, the very last dependency group of a top-level makefile 4956e45f6SSimon J. Gerraty# was not finished properly. This made it possible to add further commands 5956e45f6SSimon J. Gerraty# to that target. 6956e45f6SSimon J. Gerraty# 7956e45f6SSimon J. Gerraty# In pass 1, there is a dependency group at the bottom of the file. 8956e45f6SSimon J. Gerraty# This dependency group is not finished properly. Finishing the dependency 9956e45f6SSimon J. Gerraty# group would add the OP_HAS_COMMANDS flag to the "all" target, thereby 10956e45f6SSimon J. Gerraty# preventing any commands from being added later. 11956e45f6SSimon J. Gerraty# 12956e45f6SSimon J. Gerraty# After the file has been parsed completely, it is parsed again in pass 2. 13956e45f6SSimon J. Gerraty# In this pass, another command is added to the "current dependency group", 14956e45f6SSimon J. Gerraty# which was still the one from pass 1, which means it was possible to later 15956e45f6SSimon J. Gerraty# add commands to an existing target, even across file boundaries. 16956e45f6SSimon J. Gerraty# 17956e45f6SSimon J. Gerraty# Oops, even worse. Running this test in a make from 2020-09-25 or earlier 18956e45f6SSimon J. Gerraty# on NetBSD 8.0 x86_64 with MALLOC_OPTIONS=JA produces this or a similar 19956e45f6SSimon J. Gerraty# output: 20956e45f6SSimon J. Gerraty# 21956e45f6SSimon J. Gerraty# make: cannot open ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ. 22956e45f6SSimon J. Gerraty# 23956e45f6SSimon J. Gerraty# The 'Z' means access to already freed memory; see jemalloc(3). The cause 24956e45f6SSimon J. Gerraty# for this is that in MainParseArgs, the command line arguments were not 25956e45f6SSimon J. Gerraty# properly copied before storing them in global variables. 26956e45f6SSimon J. Gerraty 27956e45f6SSimon J. GerratyPASS?= 1 28956e45f6SSimon J. Gerraty 29956e45f6SSimon J. Gerraty.if ${PASS} == 2 30956e45f6SSimon J. Gerratyall: 31*148ee845SSimon J. Gerraty# expect+1: warning: duplicate script for target "all" ignored 32956e45f6SSimon J. Gerraty : pass 2 33956e45f6SSimon J. Gerraty.endif 34956e45f6SSimon J. Gerraty 35956e45f6SSimon J. Gerraty.if ${PASS} == 1 36956e45f6SSimon J. Gerraty 37956e45f6SSimon J. GerratyPASS= 2 38956e45f6SSimon J. Gerraty.MAKEFLAGS: -f ${.PARSEDIR:q}/${.PARSEFILE:q} 39956e45f6SSimon J. Gerraty 40956e45f6SSimon J. Gerratyall: 41*148ee845SSimon J. Gerraty# expect+1: warning: using previous script for "all" defined here 42956e45f6SSimon J. Gerraty : pass 1 43956e45f6SSimon J. Gerraty.endif 44