Mail Archives: cygwin/2003/12/04/13:35:14
Hello-
GNU Make 3.80 has a bug which causes it to try to allocate negative
amounts of memory (which ends up something like 4 gigabytes) under
certain conditions. This leads to the message:
make: *** virtual memory exhausted. Stop.
The problem is reproducible with this shell script [1]:
============== 8< ===============
for a in `seq 1 5`; do touch 0123456789012345678901234567890123$a.c;
done
cat > Makefile <<'DELIM'
define BUG
SRC := $$(wildcard *.c)
#OBJ := $$(SRC:.c=.o)
OBJ := $$(patsubst %.c,%.o,$$(SRC))
$$(OBJ):%.o:%.c
endef
$(eval $(call BUG))
DELIM
make
============== 8< ===============
It's a known bug which has been fixed in CVS for several months now, but
no version has been released in that time. The problem is affecting us
here at SDL; we have a non-recursive make structure that uses the
$(eval $(call foo)) method, and it produces this same error after only a
very few included files.
It would be great to have a fix put in the Cygwin make package. The
following patch[1] corrects the problem, and applies to the Cygwin
make-3.80-1 source.
paul
[1] The shell script and patch were adapted from notes under Debian bug
#197886 : http://bugs.debian.org/197886
diff -Naur make-3.80-1/expand.c make-3.80-1.patched/expand.c
--- make-3.80-1/expand.c 2002-07-11 00:38:57.000000000 -0600
+++ make-3.80-1.patched/expand.c 2003-12-03 16:48:06.582570500 -0700
@@ -564,3 +564,28 @@
return value;
}
+
+/* Install a new variable_buffer context, returning the current one for
+ safe-keeping. */
+
+void
+install_variable_buffer (char **bufp, unsigned int *lenp)
+{
+ *bufp = variable_buffer;
+ *lenp = variable_buffer_length;
+
+ variable_buffer = 0;
+ initialize_variable_output ();
+}
+
+/* Restore a previously-saved variable_buffer setting (free the current one).
+ */
+
+void
+restore_variable_buffer (char *buf, unsigned int len)
+{
+ free (variable_buffer);
+
+ variable_buffer = buf;
+ variable_buffer_length = len;
+}
diff -Naur make-3.80-1/function.c make-3.80-1.patched/function.c
--- make-3.80-1/function.c 2002-11-23 14:08:14.000000000 -0700
+++ make-3.80-1.patched/function.c 2003-12-03 16:48:06.598193600 -0700
@@ -1281,8 +1281,18 @@
char **argv;
const char *funcname;
{
+ char *buf;
+ unsigned int len;
+
+ /* Eval the buffer. Pop the current variable buffer setting so that the
+ eval'd code can use its own without conflicting. */
+
+ install_variable_buffer (&buf, &len);
+
eval_buffer (argv[0]);
+ restore_variable_buffer (buf, len);
+
return o;
}
diff -Naur make-3.80-1/variable.h make-3.80-1.patched/variable.h
--- make-3.80-1/variable.h 2002-08-07 18:11:19.000000000 -0600
+++ make-3.80-1.patched/variable.h 2003-12-03 16:48:06.582570500 -0700
@@ -107,6 +107,8 @@
extern char *expand_argument PARAMS ((char *str, char *end));
extern char *variable_expand_string PARAMS ((char *line, char *string,
long length));
+extern void install_variable_buffer PARAMS ((char **bufp, unsigned int *lenp));
+extern void restore_variable_buffer PARAMS ((char *buf, unsigned int len));
/* function.c */
extern int handle_function PARAMS ((char **op, char **stringp));
--
.------------------------------------------------------------.
| paul cannon pik AT debian DOT org |
| http://people.debian.org/~pik/ |
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -