pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/devel/libuv



Module Name:    pkgsrc
Committed By:   jperkin
Date:           Thu Oct  1 08:43:33 UTC 2026

Modified Files:
        pkgsrc/devel/libuv: distinfo
Added Files:
        pkgsrc/devel/libuv/patches: patch-src_unix_process.c

Log Message:
libuv: Backport https://github.com/libuv/libuv/pull/5284.

Fixes infinite loop in posix_spawn() handling which was breaking the build
of at least devel/cmake.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 pkgsrc/devel/libuv/distinfo
cvs rdiff -u -r0 -r1.1 pkgsrc/devel/libuv/patches/patch-src_unix_process.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/devel/libuv/distinfo
diff -u pkgsrc/devel/libuv/distinfo:1.89 pkgsrc/devel/libuv/distinfo:1.90
--- pkgsrc/devel/libuv/distinfo:1.89    Tue Sep 29 09:03:31 2026
+++ pkgsrc/devel/libuv/distinfo Thu Oct  1 08:43:33 2026
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.89 2026/09/29 09:03:31 adam Exp $
+$NetBSD: distinfo,v 1.90 2026/10/01 08:43:33 jperkin Exp $
 
 BLAKE2s (libuv-1.53.0.tar.gz) = 1a173a316ef190946401984bb698011ec5ae9793ea07a41553d7ebc7596a2490
 SHA512 (libuv-1.53.0.tar.gz) = 8f26c14b016368a8e382539026e1fa3cf187a7cc8bd8b50498a9b26003e9da3e48a89f4d2032694e5f152cd4177386e259b85e8280cf814153ab58950d205014
@@ -7,6 +7,7 @@ SHA1 (patch-autogen.sh) = 99790076b91d57
 SHA1 (patch-src_unix_core.c) = f6dbe539369c01e9cb870be8063d8b199393883d
 SHA1 (patch-src_unix_fs.c) = 510693bb63cac7bf25e04c64e2d231de80b149d1
 SHA1 (patch-src_unix_netbsd.c) = 071a2a853f9a73dc72e24d63316aa21b28669469
+SHA1 (patch-src_unix_process.c) = a0a02a5e9602a0f31b1ed323af049eba90688b26
 SHA1 (patch-src_unix_tty.c) = 157be1b1272dc38b3605a9822316e6cb2ddb6f22
 SHA1 (patch-src_unix_udp.c) = 88e4c08c9413095dfa0132febbc99be2e299ee8f
 SHA1 (patch-test_test-fs.c) = 8b369d45f3f88c793eeeb6fd8d8177bba14fd0ac

Added files:

Index: pkgsrc/devel/libuv/patches/patch-src_unix_process.c
diff -u /dev/null pkgsrc/devel/libuv/patches/patch-src_unix_process.c:1.1
--- /dev/null   Thu Oct  1 08:43:33 2026
+++ pkgsrc/devel/libuv/patches/patch-src_unix_process.c Thu Oct  1 08:43:33 2026
@@ -0,0 +1,127 @@
+$NetBSD: patch-src_unix_process.c,v 1.1 2026/10/01 08:43:33 jperkin Exp $
+
+Backport https://github.com/libuv/libuv/pull/5284
+
+--- src/unix/process.c.orig    2026-10-01 08:16:59.915766284 +0000
++++ src/unix/process.c
+@@ -610,11 +610,14 @@ static int uv__spawn_set_posix_spawn_fil
+     const uv_process_options_t* options,
+     int stdio_count,
+     int (*pipes)[2]) {
++  int child_fds_storage[8];
++  int* child_fds;
+   int fd;
+   int fd2;
+   int use_fd;
+   int err;
+ 
++  child_fds = child_fds_storage;
+   err = posix_spawn_file_actions_init(actions);
+   if (err != 0) {
+     /* If initialization fails, no need to de-init, just return */
+@@ -633,14 +636,25 @@ static int uv__spawn_set_posix_spawn_fil
+       goto error;
+   }
+ 
+-  /* Do not return ENOSYS after this point, as we may mutate pipes. */
++  if (stdio_count > (int) ARRAY_SIZE(child_fds_storage)) {
++    child_fds = uv__malloc(stdio_count * sizeof(*child_fds));
++    if (child_fds == NULL) {
++      err = ENOMEM;
++      goto error;
++    }
++  }
++
++  /* File actions only remap descriptors in the child. Keep the parent's
++   * descriptors intact for stream setup and cleanup. */
++  for (fd = 0; fd < stdio_count; fd++)
++    child_fds[fd] = pipes[fd][1];
+ 
+   /* First duplicate low numbered fds, since it's not safe to duplicate them,
+    * they could get replaced. Example: swapping stdout and stderr; without
+    * this fd 2 (stderr) would be duplicated into fd 1, thus making both
+    * stdout and stderr go to the same fd, which was not the intention. */
+   for (fd = 0; fd < stdio_count; fd++) {
+-    use_fd = pipes[fd][1];
++    use_fd = child_fds[fd];
+ #if defined(__APPLE__) || defined(__linux__)
+     if (use_fd < 0 || use_fd >= fd)
+       continue;
+@@ -656,24 +670,24 @@ static int uv__spawn_set_posix_spawn_fil
+       /* If we were not setting POSIX_SPAWN_CLOEXEC_DEFAULT, we would need to
+        * also consider whether fcntl(fd, F_GETFD) returned without the
+        * FD_CLOEXEC flag set. */
+-      if (pipes[fd2][1] == use_fd) {
++      if (child_fds[fd2] == use_fd) {
+         use_fd++;
+         fd2 = 0;
+       }
+     }
+     err = posix_spawn_file_actions_adddup2(
+       actions,
+-      pipes[fd][1],
++      child_fds[fd],
+       use_fd);
+     assert(err != ENOSYS);
+     if (err != 0)
+       goto error;
+-    pipes[fd][1] = use_fd;
++    child_fds[fd] = use_fd;
+   }
+ 
+   /* Second, move the descriptors into their respective places */
+   for (fd = 0; fd < stdio_count; fd++) {
+-    use_fd = pipes[fd][1];
++    use_fd = child_fds[fd];
+     if (use_fd < 0) {
+       if (fd >= 3)
+         continue;
+@@ -702,20 +716,21 @@ static int uv__spawn_set_posix_spawn_fil
+     if (err != 0)
+       goto error;
+ 
+-    /* Make sure the fd is marked as non-blocking (state shared between child
+-     * and parent). */
+-    uv__nonblock_fcntl(use_fd, 0);
++    /* Make sure standard descriptors are blocking (state shared between
++     * child and parent). Leave other inherited descriptors unchanged. */
++    if (fd <= 2)
++      uv__nonblock_fcntl(pipes[fd][1], 0);
+   }
+ 
+   /* Finally, close all the superfluous descriptors */
+   for (fd = 0; fd < stdio_count; fd++) {
+-    use_fd = pipes[fd][1];
++    use_fd = child_fds[fd];
+     if (use_fd < stdio_count)
+       continue;
+ 
+     /* Check if we already closed this. */
+     for (fd2 = 0; fd2 < fd; fd2++) {
+-      if (pipes[fd2][1] == use_fd)
++      if (child_fds[fd2] == use_fd)
+           break;
+     }
+     if (fd2 < fd)
+@@ -727,9 +742,13 @@ static int uv__spawn_set_posix_spawn_fil
+       goto error;
+   }
+ 
++  if (child_fds != child_fds_storage)
++    uv__free(child_fds);
+   return 0;
+ 
+ error:
++  if (child_fds != child_fds_storage)
++    uv__free(child_fds);
+   (void) posix_spawn_file_actions_destroy(actions);
+   return err;
+ }
+@@ -862,7 +881,6 @@ static int uv__spawn_and_init_child_posi
+   if (err != 0)
+     goto error;
+ 
+-  /* This may mutate pipes. */
+   err = uv__spawn_set_posix_spawn_file_actions(&actions,
+                                                options,
+                                                stdio_count,



Home | Main Index | Thread Index | Old Index