git-exec-intr
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Sun, 3 Dec 2023 13:23:52 +0000 (14:23 +0100)
committerAurelien Jarno <aurel32@debian.org>
Sun, 3 Dec 2023 13:23:52 +0000 (14:23 +0100)
commit 49b308a26e2a9e02ef396f67f59c462ad4171ea4
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Mon Nov 20 19:19:50 2023 +0100

    hurd: Prevent the final file_exec_paths call from signals

    Otherwise if the exec server started thrashing the old task,
    we won't be able to restart the exec.

    This notably fixes building ghc.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-exec-intr.diff

hurd/hurdexec.c
sysdeps/mach/hurd/spawni.c

index f8f174e4a214aa23c6218760dc4805e408d8d1bc..e63dea990997a97f3fbdaa70615511c64f1927a4 100644 (file)
@@ -362,6 +362,7 @@ retry:
   if (!err)
     {
       int flags;
+      sigset_t old, new;
 
       if (pdp)
        {
@@ -420,6 +421,15 @@ retry:
       if (__sigismember (&_hurdsig_traced, SIGKILL))
        flags |= EXEC_SIGTRAP;
 #endif
+
+     /* Avoid getting interrupted while exec(), notably not after the exec
+        server has committed to the exec and started thrashing us.
+
+        TODO Rather add proper interrupt support to the exec server, that
+        avoids interrupts in that period.  */
+      __sigfillset (&new);
+      __sigprocmask (SIG_SETMASK, &new, &old);
+
       err = __file_exec_paths (file, task, flags,
                               path ? path : "",
                               abspath ? abspath : "",
@@ -440,6 +450,8 @@ retry:
                           ints, INIT_INT_MAX,
                           please_dealloc, pdp - please_dealloc,
                           portnames, nportnames);
+
+      __sigprocmask (SIG_SETMASK, &old, NULL);
     }
 
   /* Release references to the standard ports.  */
index f45311a0c89986017168ff866247d04f833fc737..7c8381145cde55aa256fc5bafdacca6867c10cc8 100644 (file)
@@ -807,6 +807,18 @@ retry:
 
     inline error_t exec (file_t file)
       {
+       sigset_t old, new;
+
+       /* Avoid getting interrupted while exec(), notably not after the exec
+          server has committed to the exec and started thrashing the task.
+
+          Various issues otherwise show up when building e.g. ghc.
+
+          TODO Rather add proper interrupt support to the exec server, that
+          avoids interrupts in that period.  */
+       __sigfillset(&new);
+       __sigprocmask (SIG_SETMASK, &new, &old);
+
        error_t err = __file_exec_paths
          (file, task,
           __sigismember (&_hurdsig_traced, SIGKILL) ? EXEC_SIGTRAP : 0,
@@ -819,7 +831,7 @@ retry:
        /* Fallback for backwards compatibility.  This can just be removed
           when __file_exec goes away.  */
        if (err == MIG_BAD_ID)
-         return __file_exec (file, task,
+         err = __file_exec (file, task,
                              (__sigismember (&_hurdsig_traced, SIGKILL)
                              ? EXEC_SIGTRAP : 0),
                              args, argslen, env, envlen,
@@ -828,6 +840,8 @@ retry:
                              ints, INIT_INT_MAX,
                              NULL, 0, NULL, 0);
 
+       __sigprocmask (SIG_SETMASK, &old, NULL);
+
        return err;
       }