OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.9 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../make/0002-fix-stack-limit.patch
  5. # Copyright (C) 2010 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. bug #22010: The increased stack rlimit is inherited by the subprocesses to make.
  17. http://savannah.gnu.org/bugs/?22010
  18. http://cvs.savannah.gnu.org/viewvc/make/make.h?root=make&r1=1.132&r2=1.133&view=patch
  19. http://cvs.savannah.gnu.org/viewvc/make/main.c?root=make&r1=1.228&r2=1.229&view=patch
  20. http://cvs.savannah.gnu.org/viewvc/make/job.c?root=make&r1=1.191&r2=1.192&view=patch
  21. 2009-06-07 Paul Smith <psmith@gnu.org>
  22. * make.h: Move SET_STACK_SIZE determination to make.h.
  23. * main.c (main): New global variable, STACK_LIMIT, holds the
  24. original stack limit when make was started.
  25. * job.c (start_job_command): Reset the stack limit, if we changed it.
  26. Fixes Savannah bug #22010.
  27. diff --git a/job.c b/job.c
  28. index 3251efe..7fe08fa 100644
  29. --- a/job.c
  30. +++ b/job.c
  31. @@ -1275,6 +1275,12 @@ start_job_command (struct child *child)
  32. if (job_rfd >= 0)
  33. close (job_rfd);
  34. +#ifdef SET_STACK_SIZE
  35. + /* Reset limits, if necessary. */
  36. + if (stack_limit.rlim_cur)
  37. + setrlimit (RLIMIT_STACK, &stack_limit);
  38. +#endif
  39. +
  40. child_execute_job (child->good_stdin ? 0 : bad_stdin, 1,
  41. argv, child->environment);
  42. }
  43. @@ -2237,7 +2243,7 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
  44. "for", "case", "if", ":", ".", "break",
  45. "continue", "export", "read", "readonly",
  46. "shift", "times", "trap", "switch", "unset",
  47. - 0 };
  48. + "ulimit", 0 };
  49. char *sh_chars;
  50. char **sh_cmds;
  51. diff --git a/main.c b/main.c
  52. index 483babf..42964e0 100644
  53. --- a/main.c
  54. +++ b/main.c
  55. @@ -44,14 +44,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */
  56. # include <fcntl.h>
  57. #endif
  58. -#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
  59. -# define SET_STACK_SIZE
  60. -#endif
  61. -
  62. -#ifdef SET_STACK_SIZE
  63. -# include <sys/resource.h>
  64. -#endif
  65. -
  66. #ifdef _AMIGA
  67. int __stack = 20000; /* Make sure we have 20K of stack space */
  68. #endif
  69. @@ -213,6 +205,13 @@ int print_version_flag = 0;
  70. static struct stringlist *makefiles = 0;
  71. +/* Size of the stack when we started. */
  72. +
  73. +#ifdef SET_STACK_SIZE
  74. +struct rlimit stack_limit;
  75. +#endif
  76. +
  77. +
  78. /* Number of job slots (commands that can be run at once). */
  79. unsigned int job_slots = 1;
  80. @@ -919,11 +918,15 @@ main (int argc, char **argv, char **envp)
  81. struct rlimit rlim;
  82. /* Set the stack limit huge so that alloca does not fail. */
  83. - if (getrlimit (RLIMIT_STACK, &rlim) == 0)
  84. + if (getrlimit (RLIMIT_STACK, &rlim) == 0
  85. + && rlim.rlim_cur > 0 && rlim.rlim_cur < rlim.rlim_max)
  86. {
  87. + stack_limit = rlim;
  88. rlim.rlim_cur = rlim.rlim_max;
  89. setrlimit (RLIMIT_STACK, &rlim);
  90. }
  91. + else
  92. + stack_limit.rlim_cur = 0;
  93. }
  94. #endif
  95. diff --git a/make.h b/make.h
  96. index 994f4f2..25c2bef 100644
  97. --- a/make.h
  98. +++ b/make.h
  99. @@ -378,6 +378,14 @@ extern int no_default_sh_exe;
  100. extern int unixy_shell;
  101. #endif /* WINDOWS32 */
  102. +#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
  103. +# define SET_STACK_SIZE
  104. +#endif
  105. +#ifdef SET_STACK_SIZE
  106. +# include <sys/resource.h>
  107. +struct rlimit stack_limit;
  108. +#endif
  109. +
  110. struct floc
  111. {
  112. const char *filenm;
  113. --
  114. 1.6.5.3