Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Nov 2003 09:15:02 +0300
From:      Sergey Matveychuk <sem@ciam.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        ade@FreeBSD.org
Subject:   ports/59695: [PATCH] devel/gmake: add two patches to avoid core dumps
Message-ID:  <E1AOsx4-000692-J4@Current.sem-home.ciam.ru>
Resent-Message-ID: <200311260620.hAQ6K4xr012063@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         59695
>Category:       ports
>Synopsis:       [PATCH] devel/gmake: add two patches to avoid core dumps
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 25 22:20:04 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Sergey Matveychuk
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
System: FreeBSD Current.sem-home.ciam.ru 5.1-CURRENT FreeBSD 5.1-CURRENT #1: Fri Nov 21 07:47:47 MSK 2003
>Description:
[DESCRIBE CHANGES]
devel/gmake:
  * Add two patches to avoid core dumps on eval:
    http://savannah.gnu.org/bugs/?func=detailbug&bug_id=1516&group_id=71
    http://savannah.gnu.org/bugs/?func=detailbug&bug_id=1517&group_id=71

  * Utilize INFO macro

Added file(s):
- files/patch-eval_conditional
- files/patch-eval_crash

Port maintainer (ade@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.50
>How-To-Repeat:
>Fix:

--- gmake-3.80_2.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/devel/gmake.orig/Makefile /usr/ports/devel/gmake/Makefile
--- /usr/ports/devel/gmake.orig/Makefile	Wed Nov 26 08:53:03 2003
+++ /usr/ports/devel/gmake/Makefile	Wed Nov 26 09:02:42 2003
@@ -7,7 +7,7 @@
 
 PORTNAME=	gmake
 PORTVERSION=	3.80
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	devel
 MASTER_SITES=	${MASTER_SITE_GNU}
 MASTER_SITE_SUBDIR=	make
@@ -35,6 +35,7 @@
 CONFIGURE_ENV+=	MAKEINFO="/usr/bin/makeinfo --no-split"
 
 MAN1=		gmake.1
+INFO=		make
 
 .ifdef USE_GMAKE
 .error You have `USE_GMAKE' variable defined either in environment or in make(1) arguments. Please undefine and try again.
diff -ruN --exclude=CVS /usr/ports/devel/gmake.orig/files/patch-eval_conditional /usr/ports/devel/gmake/files/patch-eval_conditional
--- /usr/ports/devel/gmake.orig/files/patch-eval_conditional	Thu Jan  1 03:00:00 1970
+++ /usr/ports/devel/gmake/files/patch-eval_conditional	Wed Nov 26 08:53:29 2003
@@ -0,0 +1,150 @@
+Index: read.c
+===================================================================
+RCS file: /cvsroot/make/make/read.c,v
+retrieving revision 1.124
+diff -u -B -b -r1.124 read.c
+--- read.c	14 Oct 2002 21:54:04 -0000	1.124
++++ read.c	25 Oct 2002 21:17:42 -0000
+@@ -272,6 +272,34 @@
+   return read_makefiles;
+ }
+ 
++/* Install a new conditional and return the previous one.  */
++
++static struct conditionals *
++install_conditionals (struct conditionals *new)
++{
++  struct conditionals *save = conditionals;
++
++  bzero ((char *) new, sizeof (*new));
++  conditionals = new;
++
++  return save;
++}
++
++/* Free the current conditionals and reinstate a saved one.  */
++
++static void
++restore_conditionals (struct conditionals *saved)
++{
++  /* Free any space allocated by conditional_line.  */
++  if (conditionals->ignoring)
++    free (conditionals->ignoring);
++  if (conditionals->seen_else)
++    free (conditionals->seen_else);
++
++  /* Restore state.  */
++  conditionals = saved;
++}
++
+ static int
+ eval_makefile (char *filename, int flags)
+ {
+@@ -388,6 +416,8 @@
+ eval_buffer (char *buffer)
+ {
+   struct ebuffer ebuf;
++  struct conditionals *saved;
++  struct conditionals new;
+   const struct floc *curfile;
+   int r;
+ 
+@@ -402,8 +432,12 @@
+   curfile = reading_file;
+   reading_file = &ebuf.floc;
+ 
++  saved = install_conditionals (&new);
++
+   r = eval (&ebuf, 1);
+ 
++  restore_conditionals (saved);
++
+   reading_file = curfile;
+ 
+   return r;
+@@ -412,13 +446,8 @@
+ 
+ /* Read file FILENAME as a makefile and add its contents to the data base.
+ 
+-   SET_DEFAULT is true if we are allowed to set the default goal.
+-
+-   FILENAME is added to the `read_makefiles' chain.
++   SET_DEFAULT is true if we are allowed to set the default goal.  */
+ 
+-   Returns 0 if a file was not found or not read.
+-   Returns 1 if FILENAME was found and read.
+-   Returns 2 if FILENAME was read, and we kept a reference (don't free it).  */
+ 
+ static int
+ eval (struct ebuffer *ebuf, int set_default)
+@@ -782,9 +811,7 @@
+ 
+ 	  /* Save the state of conditionals and start
+ 	     the included makefile with a clean slate.  */
+-	  save = conditionals;
+-	  bzero ((char *) &new_conditionals, sizeof new_conditionals);
+-	  conditionals = &new_conditionals;
++	  save = install_conditionals (&new_conditionals);
+ 
+ 	  /* Record the rules that are waiting so they will determine
+ 	     the default goal before those in the included makefile.  */
+@@ -810,14 +837,8 @@
+                 }
+ 	    }
+ 
+-	  /* Free any space allocated by conditional_line.  */
+-	  if (conditionals->ignoring)
+-	    free (conditionals->ignoring);
+-	  if (conditionals->seen_else)
+-	    free (conditionals->seen_else);
+-
+-	  /* Restore state.  */
+-	  conditionals = save;
++	  /* Restore conditional state.  */
++	  restore_conditionals (save);
+ 
+           goto rule_complete;
+ 	}
+Index: tests/scripts/functions/eval
+===================================================================
+RCS file: /cvsroot/make/make/tests/scripts/functions/eval,v
+retrieving revision 1.1
+diff -u -B -b -r1.1 eval
+--- tests/scripts/functions/eval	8 Jul 2002 02:26:48 -0000	1.1
++++ tests/scripts/functions/eval	25 Oct 2002 21:17:42 -0000
+@@ -57,4 +57,35 @@
+ 
+ &compare_output($answer,&get_logfile(1));
+ 
++# Test to make sure eval'ing inside conditionals works properly
++
++$makefile3 = &get_tmpfile;
++
++open(MAKEFILE,"> $makefile3");
++
++print MAKEFILE <<'EOF';
++FOO = foo
++
++all:: ; @echo it
++
++define Y
++  all:: ; @echo worked
++endef
++
++ifdef BAR
++$(eval $(Y))
++endif
++
++EOF
++
++close(MAKEFILE);
++
++&run_make_with_options($makefile3, "", &get_logfile);
++$answer = "it\n";
++&compare_output($answer,&get_logfile(1));
++
++&run_make_with_options($makefile3, "BAR=1", &get_logfile);
++$answer = "it\nworked\n";
++&compare_output($answer,&get_logfile(1));
++
+ 1;
diff -ruN --exclude=CVS /usr/ports/devel/gmake.orig/files/patch-eval_crash /usr/ports/devel/gmake/files/patch-eval_crash
--- /usr/ports/devel/gmake.orig/files/patch-eval_crash	Thu Jan  1 03:00:00 1970
+++ /usr/ports/devel/gmake/files/patch-eval_crash	Wed Nov 26 08:53:29 2003
@@ -0,0 +1,77 @@
+Index: variable.h
+===================================================================
+RCS file: /cvsroot/make/make/variable.h,v
+retrieving revision 1.24
+diff -u -B -b -r1.24 variable.h
+--- variable.h	8 Aug 2002 00:11:19 -0000	1.24
++++ variable.h	25 Oct 2002 21:37:32 -0000
+@@ -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));
+Index: expand.c
+===================================================================
+RCS file: /cvsroot/make/make/expand.c,v
+retrieving revision 1.33
+diff -u -B -b -r1.33 expand.c
+--- expand.c	14 Oct 2002 21:54:04 -0000	1.33
++++ expand.c	25 Oct 2002 21:37:32 -0000
+@@ -545,3 +545,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;
++}
+Index: function.c
+===================================================================
+RCS file: /cvsroot/make/make/function.c,v
+retrieving revision 1.71
+diff -u -B -b -r1.71 function.c
+--- function.c	14 Oct 2002 21:54:04 -0000	1.71
++++ function.c	25 Oct 2002 21:37:32 -0000
+@@ -1196,7 +1196,17 @@
+ static char *
+ func_eval (char *o, 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 -ruN --exclude=CVS /usr/ports/devel/gmake.orig/pkg-plist /usr/ports/devel/gmake/pkg-plist
--- /usr/ports/devel/gmake.orig/pkg-plist	Wed Nov 26 08:53:03 2003
+++ /usr/ports/devel/gmake/pkg-plist	Wed Nov 26 09:00:30 2003
@@ -1,7 +1,4 @@
 bin/gmake
-@unexec install-info --delete %D/info/make.info %D/info/dir
-info/make.info
-@exec install-info %D/info/make.info %D/info/dir
 %%NLS%%share/locale/da/LC_MESSAGES/make.mo
 %%NLS%%share/locale/de/LC_MESSAGES/make.mo
 %%NLS%%share/locale/es/LC_MESSAGES/make.mo
--- gmake-3.80_2.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1AOsx4-000692-J4>