hello GNU Make maintainers, i was writing a bunch of makefiles, and i wanted to use $(call VARIABL) in my makefile, but if the VARIABLE referenced itself, it gave segmentation fault. here is a stripped down version of the makefile which segfaults for me always.
--snip-Makefile-- CMD=echo all: CMD=$(CMD) foo all: $(call CMD) --snip-Makefile-- this above makefile makes make segfualt. obviously the segfault does not happen if the line was changed to `all: VAR:=$(VAR) foo' the `problem' was that, in func_call(), the CMD's "struct variable"'s `exp_count' is set to EXP_COUNT_MAX (32k odd), which caused variable_expand_string () to recurse upto 32k times.. and my make was segfualting as my stack ran out before that. if somehow on your machine the stack limits are bigger, then you might not see the segfault. Here is a snapshot to show that it did in my box --snip--snapshot-- guhnoo:/tmp$ uname -a Linux guhnoo 2.6.14.3 #1 PREEMPT Thu Dec 22 15:52:01 IST 2005 i686 unknown unknown GNU/Linux guhnoo:/tmp$ make --version GNU Make 3.80 Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. guhnoo:/tmp$ cat Makefile CMD=echo all: CMD=$(CMD) foo all: $(call CMD) guhnoo:/tmp$ make all Segmentation fault guhnoo:/tmp$ --snip-screenshot-- i do read a changelog entry in 2002-04-28 telling that exp_count contains max number of recursive calls allowed. but i do not understand why $(CMD) gets set with exp_count=0 while $(call CMD) gets set with exp_count=EXP_COUNT_MAX.. shouldnt their expansion principles be the same? i am assuming the difference could be, for call, $1 could contain the CMD again, or something like that? even if exp_count > 0 is needed, EXP_COUNT_MAX is proving to be too big a value. I re-built make with setting exp_count=0 in func_call(), in the place where it was being set to EXP_COUNT_MAX [diff attached], and i found all the test cases i could build, worked.. do we really need exp_count > 0 there? could you show me an example Makefile where exp_count=<arbitrary number> `works' or `helps'. regards, avati -- Anand V. Avati
Index: function.c =================================================================== RCS file: /cvsroot/make/make/function.c,v retrieving revision 1.91 diff -p -u -r1.91 function.c --- function.c 17 Nov 2005 07:27:28 -0000 1.91 +++ function.c 8 Jan 2006 10:51:24 -0000 @@ -2213,7 +2213,7 @@ func_call (char *o, char **argv, const c /* Expand the body in the context of the arguments, adding the result to the variable buffer. */ - v->exp_count = EXP_COUNT_MAX; + v->exp_count = 0; saved_args = max_args; max_args = i;
_______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make