rpms/make/devel make-3.81-rlimit.patch, NONE, 1.1 make.spec, 1.29, 1.30

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Thu Jan 25 12:00:41 UTC 2007


Author: pmachata

Update of /cvs/dist/rpms/make/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv4784

Modified Files:
	make.spec 
Added Files:
	make-3.81-rlimit.patch 
Log Message:
- make now restores rlimit to its original values before launching
  subprocess (#214033)
- this doesn't resolve #214033, it's merely related


make-3.81-rlimit.patch:
 job.c  |    3 +++
 main.c |   59 ++++++++++++++++++++++++++++++++++++++++++++---------------
 make.h |    7 +++++++
 3 files changed, 54 insertions(+), 15 deletions(-)

--- NEW FILE make-3.81-rlimit.patch ---
diff -Burp make-3.81/job.c make-3.81-pm/job.c
--- make-3.81/job.c	2006-11-30 11:00:23.000000000 +0100
+++ make-3.81-pm/job.c	2006-11-30 10:58:46.000000000 +0100
@@ -2079,6 +2079,9 @@ exec_command (char **argv, char **envp)
 # else
 
   /* Run the program.  */
+#ifdef SET_STACK_SIZE
+  restore_original_stack_rlimit ();
+#endif
   environ = envp;
   execvp (argv[0], argv);
 
diff -Burp make-3.81/main.c make-3.81-pm/main.c
--- make-3.81/main.c	2006-11-30 11:00:23.000000000 +0100
+++ make-3.81-pm/main.c	2006-11-30 10:38:04.000000000 +0100
@@ -44,12 +44,51 @@ Foundation, Inc., 51 Franklin St, Fifth 
 # include <fcntl.h>
 #endif
 
-#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
-# define SET_STACK_SIZE
-#endif
-
 #ifdef SET_STACK_SIZE
 # include <sys/resource.h>
+/* Whether the rlimit was set successfuly */
+static int setrlimit_succeeded = 0;
+/* Original rlim_cur */
+static rlim_t setrlimit_orig_cur = 0;
+
+/* Get rid of any avoidable limit on stack size so that alloca does
+   not fail. */
+void
+set_max_stack_rlimit (void)
+{
+  struct rlimit rlim;
+
+  /* Back off if the limit is still set, probably due to failure in
+     restore_original_stack_rlimit. */
+  if (setrlimit_succeeded)
+    return;
+
+  if (getrlimit (RLIMIT_STACK, &rlim) == 0)
+    {
+      setrlimit_orig_cur = rlim.rlim_cur;
+      rlim.rlim_cur = rlim.rlim_max;
+      if (setrlimit (RLIMIT_STACK, &rlim) != -1)
+	setrlimit_succeeded = 1;
+    }
+}
+
+/* Set the rlimit back to its original value.  To be called before
+   process spawn. */
+void
+restore_original_stack_rlimit (void)
+{
+  struct rlimit rlim;
+
+  if (!setrlimit_succeeded)
+    return;
+
+  if (getrlimit (RLIMIT_STACK, &rlim) == 0)
+    {
+      rlim.rlim_cur = setrlimit_orig_cur;
+      if (setrlimit (RLIMIT_STACK, &rlim) != -1)
+	setrlimit_succeeded = 0;
+    }
+}
 #endif
 
 #ifdef _AMIGA
@@ -915,17 +954,7 @@ main (int argc, char **argv, char **envp
 #endif
 
 #ifdef SET_STACK_SIZE
- /* Get rid of any avoidable limit on stack size.  */
-  {
-    struct rlimit rlim;
-
-    /* Set the stack limit huge so that alloca does not fail.  */
-    if (getrlimit (RLIMIT_STACK, &rlim) == 0)
-      {
-        rlim.rlim_cur = rlim.rlim_max;
-        setrlimit (RLIMIT_STACK, &rlim);
-      }
-  }
+  set_max_stack_rlimit ();
 #endif
 
 #ifdef HAVE_ATEXIT
diff -Burp make-3.81/make.h make-3.81-pm/make.h
--- make-3.81/make.h	2006-11-30 11:00:23.000000000 +0100
+++ make-3.81-pm/make.h	2006-11-30 10:29:50.000000000 +0100
@@ -346,6 +346,13 @@ extern int strcmpi (const char *,const c
 #define N_(msgid)           gettext_noop (msgid)
 #define S_(msg1,msg2,num)   ngettext (msg1,msg2,num)
 
+/* Handle rlimit */
+#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
+# define SET_STACK_SIZE
+void set_max_stack_rlimit (void);
+void restore_original_stack_rlimit (void);
+#endif
+
 /* Handle other OSs.  */
 #if defined(HAVE_DOS_PATHS)
 # define PATH_SEPARATOR_CHAR ';'


Index: make.spec
===================================================================
RCS file: /cvs/dist/rpms/make/devel/make.spec,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- make.spec	12 Jul 2006 07:17:38 -0000	1.29
+++ make.spec	25 Jan 2007 12:00:34 -0000	1.30
@@ -2,7 +2,7 @@
 Name: make
 Epoch: 1
 Version: 3.81
-Release: 1.1
+Release: 2%{?dist}
 License: GPL
 Group: Development/Tools
 URL: http://www.gnu.org/software/make/
@@ -12,6 +12,7 @@
 Patch5: make-3.80-getcwd.patch
 Patch6: make-3.81-err-reporting.patch
 Patch7: make-3.81-memory.patch
+Patch8: make-3.81-rlimit.patch
 Prereq: /sbin/install-info
 Prefix: %{_prefix}
 Buildroot: %{_tmppath}/%{name}-root
@@ -34,6 +35,7 @@
 %patch5 -p1
 %patch6 -p1
 %patch7 -p1
+%patch8 -p1
 
 %build
 config/missing --run aclocal -I config
@@ -81,6 +83,10 @@
 %{_infodir}/*.info*
 
 %changelog
+* Thu Jan 25 2007 Petr Machata <pmachata at redhat.com> - 1:3.81-2
+- make now restores rlimit to its original values before launching
+  subprocess (#214033)
+
 * Wed Jul 12 2006 Jesse Keating <jkeating at redhat.com> - 1:3.81-1.1
 - rebuild
 




More information about the fedora-cvs-commits mailing list