bug fix for 3.79 and 3.80

2003-01-29 Thread Steve Brown
Title: bug fix for 3.79 and 3.80






Hi,


I came across a bug today that causes make 3.79 and 3.80  to print 'Malformed per-target variable definition', and sometimes causes it to core-dump on long target names.

The problem is that the eval() function in read.c reallocs memory if you have long target names (>200 chars) put leaves the 'p' pointer at the old address (line 1049 in make-3.80 read.c)

Here's a makefile that reproduces the problem:


% cat makefile


base_metals_fmd_reports.sun5 base_metals_fmd_reports CreateRealPositions CreateMarginFunds deals_changed_since : BUILD_OBJ=$(shell if [ -f "build_information.generate" ]; then echo "$(OBJ_DIR)/build_information.o"; fi )

% make
makefile:3: Malformed per-target variable definition
Segmentation fault


And here's the fix:
% diff -ur read.c ../../make-3.80.new/read.c 
--- read.c  Fri Oct  4 12:13:42 2002
+++ ../../make-3.80.new/read.c  Wed Jan 29 17:55:57 2003
@@ -1018,9 +1018,11 @@
 if (*lb_next != '\0')
   {
 unsigned int l = p2 - variable_buffer;
+    unsigned int l2 = p - variable_buffer;
 plen = strlen (p2);
 (void) variable_buffer_output (p2+plen,
    lb_next, strlen (lb_next)+1);
+    p = variable_buffer + l2;
 p2 = variable_buffer + l;
   }
 
@@ -1045,9 +1047,11 @@
    after it.  */
 if (semip)
   {
+    unsigned int l2 = p - variable_buffer;
 *(--semip) = ';';
 variable_buffer_output (p2 + strlen (p2),
 semip, strlen (semip)+1);
+    p = variable_buffer + l2;
   }
 record_target_var (filenames, p, two_colon, v_origin, fstart);
 filenames = 0;



I've submitted patch on savannah: patch id 1022



cheers,
Steve



___
Bug-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-make



Re: GNU make 3.80 build failure on FreeBSD 5

2003-01-29 Thread Paul D. Smith
OK, thanks.

-- 
---
 Paul D. Smith <[EMAIL PROTECTED]>  Find some GNU make tips at:
 http://www.gnu.org  http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


___
Bug-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-make



Possible GNU Make bug

2003-01-29 Thread David Buehler
I'm expecting this makefile to echo "mylib", but it echos "Makefile" then
"mylib"... perhaps there's something esoteric going on that I haven't
figured out from the documentation.

Running on Debian GNU/Linux Stable.  I installed make version 3.80 just to
check that the behavior is the same as 3.79.1, and it is.

...David...

Script started on Wed Jan 29 15:56:31 2003
[rdppsoft] 1 > ~/gnu/bin/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.
[rdppsoft] 2 >
[rdppsoft] 2 >
[rdppsoft] 2 > cat Makefile
all : mylib

.PHONY : all force

%:force
echo $@
[rdppsoft] 3 >
[rdppsoft] 3 >
[rdppsoft] 3 > ~/gnu/bin/make
echo Makefile
Makefile
echo mylib
mylib
[rdppsoft] 4 >
[rdppsoft] 4 >
[rdppsoft] 4 > make --version
GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
Built for i386-pc-linux-gnu
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
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.

Report bugs to <[EMAIL PROTECTED]>.

[rdppsoft] 5 > make
echo Makefile
Makefile
echo mylib
mylib
[rdppsoft] 6 >
Script done on Wed Jan 29 15:57:06 2003


all : mylib

.PHONY : all force

%:force
echo $@

___
Bug-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-make



Re: Possible GNU Make bug

2003-01-29 Thread Paul D. Smith
%% David Buehler <[EMAIL PROTECTED]> writes:

  db> I'm expecting this makefile to echo "mylib", but it echos
  db> "Makefile" then "mylib"... perhaps there's something esoteric
  db> going on that I haven't figured out from the documentation.

The latter :).

Check the GNU make manual section "How Makefiles are Remade", in
particular the second paragraph.  Because you have a match-anything
rule, that is forced, your makefile will try to be remade every time.

-- 
---
 Paul D. Smith <[EMAIL PROTECTED]>  Find some GNU make tips at:
 http://www.gnu.org  http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


___
Bug-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-make