bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problem in $(call ...) [func_call()]


From: Anand Avati
Subject: problem in $(call ...) [func_call()]
Date: Sun, 8 Jan 2006 16:56:45 +0530
User-agent: Mutt/1.4.2.1i

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

Attachment: make.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]