[gnu.utils.bug] gnu make bug

wsd@CS.BROWN.EDU (02/20/89)

I am running on a sun4-110 running sunos4.0
My version of gnu make has the following version info:

	GNU Make version 3.05, by Richard Stallman and Roland McGrath.
	Copyright (C) 1988 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.

when I give it this makefile (the file is named crasher):

	cfiles = $(wildcard *.c)
	
	test:   ;
		echo cfiles  $(cfiles)

I get the following output:

	./make -f crasher

	echo cfiles
	cfiles

This is incorrect, as there are several .c files in the current
directory (I am running in the gnu make source directory).

When we examined the code, the bug raised its ugly head in
glob.c:glob_filename on line 432.

	directory_name = (char *)alloca (i);

where i is 0.  alloca returns the same value as it returned the
last time it was called (the previous line, when filename) was
allocated.  Then on line 448

	directory_name[i] = '\0';

since directory_name really points to filename, filename gets trashed.
Even if i is not 0, since directory_name has exactly i bytes allocated
to it, directory_name[i] is out of bounds.  For some reason this
works on a sun 3.

The correction we made (which works so far) is to change line 432 to
read
	  directory_name = (char *)alloca (i + 1);


Scott Draves and Nick Thompson

djk@MORITZ.CS.COLUMBIA.EDU (David Kurlander) (06/06/89)

Here's a pretty significant bug I found in gnu make, version 3.48.

Given the following makefile, the third echo does not print what I
would expect.  It echoes "${SRC}".  I would expect it to echo "foo.o
fee.o".

By the way, I really like your program, and I think that you're doing
a fine service for the community.

David Kurlander
djk@cs.columbia.edu

--------
SRC = foo.c fee.c
SRC2 = ${SRC}

echo:
	echo ${SRC:.c=.o}
	echo ${SRC2}
	echo ${SRC2:.c=.o}