Avoid fork bomb caused by native compilation trampolines
authorAndrea Corallo <andrea.corallo@arm.com>
Tue, 18 Oct 2022 13:14:32 +0000 (15:14 +0200)
committerSean Whitton <spwhitton@spwhitton.name>
Thu, 27 Oct 2022 22:35:03 +0000 (15:35 -0700)
This upstream patch has been incorporated to fix the problem:

  Set `comp-no-spawn' earlier using -no-comp-spawn

  * src/emacs.c (standard_args): Add '-no-comp-spawn' cmd line option.
  * lisp/startup.el (command-line): Parse '-no-comp-spawn' cmd line
  option.
  * lisp/emacs-lisp/comp.el (comp-run-async-workers, comp-final):
  Use '-no-comp-spawn'.

Origin: upstream, commit: 5ad5b797f78dacb9c901d3c63bee05b1762fa94f
Bug-Debian: https://bugs.debian.org/1017817
Bug-Debian: https://bugs.debian.org/1017845
Forwarded: not-needed

lisp/emacs-lisp/comp.el
lisp/startup.el
src/emacs.c

index dc94b907cfbdb764631112f7c944a0b8c743fadd..fb0d3805da40085f017401fd7a7b457c3a17c624 100644 (file)
@@ -3680,8 +3680,7 @@ Prepare every function for final compilation and drive the C back-end."
              (print-circle t)
              (print-escape-multibyte t)
              (expr `((require 'comp)
-                     (setf comp-no-spawn t
-                           native-comp-verbose ,native-comp-verbose
+                     (setf native-comp-verbose ,native-comp-verbose
                            comp-libgccjit-reproducer ,comp-libgccjit-reproducer
                            comp-ctxt ,comp-ctxt
                            native-comp-eln-load-path ',native-comp-eln-load-path
@@ -3707,7 +3706,8 @@ Prepare every function for final compilation and drive the C back-end."
               (if (zerop
                    (call-process (expand-file-name invocation-name
                                                    invocation-directory)
-                                nil t t "--batch" "-l" temp-file))
+                                nil t t "-no-comp-spawn" "--batch" "-l"
+                                 temp-file))
                   (progn
                     (delete-file temp-file)
                     output)
@@ -3943,7 +3943,6 @@ display a message."
                                  native-comp-verbose ,native-comp-verbose
                                  comp-libgccjit-reproducer ,comp-libgccjit-reproducer
                                  comp-async-compilation t
-                                 comp-no-spawn t
                                  native-comp-eln-load-path ',native-comp-eln-load-path
                                  native-comp-compiler-options
                                  ',native-comp-compiler-options
@@ -3978,7 +3977,8 @@ display a message."
                              :command (list
                                        (expand-file-name invocation-name
                                                          invocation-directory)
-                                       "--batch" "-l" temp-file)
+                                       "-no-comp-spawn" "--batch" "-l"
+                                       temp-file)
                              :sentinel
                              (lambda (process _event)
                                (run-hook-with-args
index 052ba7b2c66ce34dc7507a53c243cad77fe78991..0f5de5affc38d4191cbcf945a19fdc2dce958a88 100644 (file)
@@ -1143,7 +1143,8 @@ please check its value")
                          ("--no-x-resources") ("--debug-init")
                          ("--user") ("--iconic") ("--icon-type") ("--quick")
                         ("--no-blinking-cursor") ("--basic-display")
-                         ("--dump-file") ("--temacs") ("--seccomp")))
+                         ("--dump-file") ("--temacs") ("--seccomp")
+                        ("--no-comp-spawn")))
              (argi (pop args))
              (orig-argi argi)
              argval)
@@ -1189,6 +1190,9 @@ please check its value")
         ((equal argi "-no-site-file")
          (setq site-run-file nil)
          (put 'site-run-file 'standard-value '(nil)))
+         ((equal argi "-no-comp-spawn")
+          (defvar comp-no-spawn)
+          (setq comp-no-spawn t))
         ((equal argi "-debug-init")
          (setq init-file-debug t))
         ((equal argi "-iconic")
index 0a90b0913be223a2ac92c0e4d2bf6225dfba754d..3e75cd3622e92184959b36856d88634d3f4ff8e6 100644 (file)
@@ -2402,6 +2402,7 @@ static const struct standard_args standard_args[] =
   { "-no-init-file", 0, 50, 0 },
   { "-no-x-resources", "--no-x-resources", 40, 0 },
   { "-no-site-file", "--no-site-file", 40, 0 },
+  { "-no-comp-spawn", "--no-comp-spawn", 60, 0 },
   { "-u", "--user", 30, 1 },
   { "-user", 0, 30, 1 },
   { "-debug-init", "--debug-init", 20, 0 },