URL: <http://savannah.gnu.org/bugs/?40159>
Summary: Premature exit with incorrect error message, or garbage output characters. Project: make Submitted by: padavo Submitted on: Wed 02 Oct 2013 05:39:01 PM GMT Severity: 3 - Normal Item Group: Bug Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Component Version: 3.81 Operating System: POSIX-Based Fixed Release: None Triage Status: None _______________________________________________________ Details: I am seeing a bug with the Gnu Make parsing under certain conditions. It behaves like runtime corruption of internal data structures that is rarely triggered. On debian 7: $ dpkg -s make Architecture: i386 Version: 3.81-8.2 Here is a complete minimal example makefile that I hope will demonstrate it. If the long foreach lines have been line-wrapped by this web interface, please restore them to a single line each as indicated by their newline escapes. -------------------------------------- .PHONY: dummy dummy: # lazy evaluation, refer Mecklenburg "GNU Make" 3ed p189-190 define lazy $1 = $$($1_lazy) $$($1) $1_lazy = $$(eval $1 := $2) endef define def $(eval $(call lazy,ooo,i)) $(warning $(ooo)) endef $(foreach x,X X X X X X X X ,\ $(foreach y,Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y ,\ $(eval $(call def,A,B)))) -------------------------------------- Running 'make -R -r' with the above makefile gives Makefile:15: i (repeated 100 times followed by) Makefile:15: *** unterminated variable reference. Stop. It does not complete all of the foreach expansions, and exits with status=2. The purpose of the strange foreach arguments is to stimulate this bug to appear both in bash and under gdb. If these are shortened, the bug does not appear. More evidence that bad things are happening internally can be seen by trivially changing the variable name from 'ooo' to 'oo', ie two lines are changed as follows: define def $(eval $(call lazy,oo,y)) $(warning $(oo)) endef Running with this change, the above error does not occur! The foreach completes, and all the strings printed by $(warning $(oo)) include 'i' character as expected. However several long groups of them have an extra garbage character after the 'i', such as byte 18hex (ASCII cancel character). So something bad is happening there still, even though the exit status is zero. I also observe that all these symptoms might disappear depending on other apparently random factors such as what files might be present in the current directory, editing comments in the makefile, or running under gdb. Also this bug likes to hide, it took several hours of trial and error for me to produce this minimal example which consistently demonstrates it in an empty directory. Small edits to the example are likely to make the bug disappear. I hope it actually occurs on your machine. I tested this on two different hardware. _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?40159> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make