[pull] v1.x from libuv:v1.x#190
Open
pull[bot] wants to merge 933 commits into
Open
Conversation
On macOS, when calling `spawn`, the child process's stdio buffer size is 8192 bytes. This is due to the AF_UNIX socket buffer size being 8192 bytes in the XNU kernel. When large amounts of data are transferred through the child process's stdio, this buffer size can cause performance issues. To mitigate this, the buffer size has been increased to 65536 bytes, aligning it with the behavior on Linux.
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Extend uv_fs_utime, uv_fs_futime and uv_fs_lutime to accept NAN and INFINITY, with NAN meaning "don't touch the timestamp" and INFINITY meaning "set to the current timestamp." Ugly, but it avoids having to add uv_fs_utime2, etc. UV_FS_UTIME_NOW and UV_FS_UTIME_OMIT constants have been added to make it more palatable. Fixes: #4665
Windows provides the `ENABLE_VIRTUAL_TERMINAL_INPUT` flag for TTY input streams as a companion flag to `ENABLE_VIRTUAL_TERMINAL_PROCESSING`, which libuv is already setting for TTY output streams. Setting this flag lets the terminal emulator perform some of the processing that libuv already currently does for input events, but most notably enables receiving control sequences that are otherwise entirely unavailable, e.g. for bracketed paste (which the Node.js readline implementation added basic support for in nodejs/node@87af913b66eab78088acfd). libuv currently already provides translations for key events to control sequences, i.e. what this mode is intended to provide, but libuv does not and cannot translate all such events. Since the control sequences differ from the ones that Windows has chosen to standardize on, and applications may not be expecting this change, this is opt-in for now (but ideally will be the default behavior starting in libuv v2.x, should that ever happen). Another downside of this change is that not all shells reset this mode when an application exits. For example, when running a Node.js program with this flag enabled inside of PowerShell in Windows terminal, if the application exits while in raw TTY input mode, neither the shell nor the terminal emulator reset this flag, rendering the input stream unusable. While there's general awareness of the problem that console state is global state rather than per-process (same as on UNIX platforms), it seems that applications like PowerShell aren't expecting to need to unset this flag on the input stream, only its output counterpart (e.g. https://github.com/PowerShell/PowerShell/blob/4e7942135f998ab40fd3ae298b020e161a76d4ef/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs#L1156). Hence, `uv_tty_reset_mode()` is extended to reset the terminal to its original state if the new mode is being used. Refs: nodejs/node@87af913 Refs: microsoft/terminal#4954
Solaris provides sendmmsg() as of 11.3.32. It was added at the same time as MSG_WAITFORONE. The same is seen in Illumos guarded by __BSD_VISIBLE Fixes: #4715
Allocate storage upfront, that way we can never run out of memory halfway through processing the interface list. Fixes: #4723
On OpenBSD we do not know the cpuspeed in same cases (mostly arm64) and the HW_CPUSPEED sysctl will return EOPNOTSUPP in that case, which can be ignored because we still need the rest of the CPU information.
uv_thread_getname is not available on aix and ibm i Same issue as thread_name test Refs: #4599 (comment)
Solaris 11.4 has Load Balancing for SO_REUSEPORT, but setting SO_REUSEADDR disables load balancing. As per comments in test/test-udp-reuseport.c prefer SO_REUSEPORT when available. With these changes in place udp-reuseport testing passes. BIND (named), which uses routing sockets which cause ENOPROTOOPT to be returned when SO_REUSEPORT is requested, also continues to work with the change. Notes: - The use of getsockopt() to query if SO_REUSEPORT was available was erroneous. - Selectively limiting SO_REUSEPORT setting to specific types of socket was considered but not entertained. - Oracle will investigate if the setting of SO_REUSEADDR was intentionally meant to prevent load balancing. - Adding a test for routing sockets is left for future work.
In function main, the pointer lib allocated at line 7 is passed as an argument to functions uv_dlopen at line 10, uv_dlerror at lines 11 and 17, and uv_dlsym at line 16, but it is never freed before the function returns at line 24. This results in a memory leak bug.
Fixes: #4734 Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Rename the `handle` parameter of `timer_close_cb`'s declaration to `timer` to match the definition.
This commit updates the test runner's print_lines() logic to better handle partial lines.
After 14 years that should be fairly safe, right? Right!? Not safe enough for Windows Server 2016 apparently; there are build errors coming from system headers. The GHA images are slated for removal in a month anyway so upgrade them to Windows Server 2025. Fixes: #4742
Documentation on Linux explains that nul bytes have no special significance in abstract namespace socket names. Avoid precluding such addresses. Signed-off-by: Itay Bookstein <ibookstein@gmail.com>
Solaris implemented pipe2 in 11.4 and illumos have had it since 2013. Ref: https://docs.oracle.com/cd/E88353_01/html/E37841/pipe2-2.html https://illumos.org/man/2/pipe2 https://www.illumos.org/issues/3714
Use fchmod() on platforms that support it on UNIX sockets. Only fall back to chmod() on platforms that don't (macOS and the BSDs.) Remove the stat + chmod dance from the fallback and just call chmod directly, because that's another source of TOCTOU issues. Fixes: #2040
On some platforms (like GNU/Hurd), `getsockname` returns an empty string for sockets in the UNIX domain. However, we do have stored the path info in `pipe_fname` of `uv_pipe_t`, so we can try with it if `getsockname` returns an empty string.
Haiku has parallel types to stdint.h, and their APIs use these types. In the Haiku-specific haiku.h file, it is passing an address of a uint32_t to get_cpu_topology_info(), that expects the other uint32: https://github.com/haiku/haiku/blob/648fa5897c28d5a4c8a5b4992dbf9b9d410434c8/src/system/libroot/os/system_info.cpp#L187 You get an "incompatible-pointer-types" warning in gcc if the warnings are turned up. But if you pass the pointer to Haiku's notion of uint32, then the warning goes away.
Guard `udp_recvmsg_unreachable_error6` in case ipv6 is not supported. Fixes: #5143
After the fix to limit the max size of uv_fs_sendfile, this code became incorrect and would busy-loop. It was previously trying to work around the fact that the return value of uv_fs_sendfile was undefined when the input argument SSIZE_MAX > INT32_MAX, but that meant it had to ignore errors. Using the more correct UV__IO_MAX_BYTES value also avoids any UB with checking the result of uv_fs_sendfile.
With a environment larger than PATH_MAX, AI thinks the loop here could theoretically write a null byte after `b` when spawning a path of size NAME_MAX. Re-write this size-check to be a bit less confusing. The original musl code used a VLA of size `min(PATH_MAX, strlen(p)) + 1`.
Create a manual database for CI to make sure that folks cannot accidentally change a struct size on a supported platform. Use `./uv_run_tests sizeof sizeof` to regenerate the list. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The fast relaxed read makes this function very difficult and slow to use correctly, since it means many callers are required to have a fence instruction instead. Making this always a seq_cst barrier on the pending field should eliminate an unexpected source of concurrency bugs.
Register the eventfd with EPOLLET to enable edge-triggered notification where we're able to eliminate the overhead of reading the eventfd via system call on each wakeup event. When the eventfd counter reaches the maximum value of the unsigned 64-bit, which may not happen for the entire lifetime of the process, we rewind the counter and retry. This optimization saves one system call on each event-loop wakeup, eliminating the overhead of `read(2)` as well as the extra latency for each epoll wakeup. Relands #4400 Co-authored-by: Andy Pan <i@andypan.me>
…5158) - fix sizeof/ARRAY_SIZE confusion in GetModuleBaseNameW call GetModuleBaseNameW expects nSize as a count of WCHARs, but sizeof(basename) returns bytes (520), causing the API to believe the buffer is twice its actual capacity (260 WCHARs). Use ARRAY_SIZE(basename) to pass the correct element count, consistent with the _snwprintf_s calls later in the same function. This API already had a cap of 255 characters per MAX_NAME on NTFS, so it a non-functional change. - fix uninitialized variables in uv__kill SIGQUIT path Three issues in the SIGQUIT dump-writing path: - basename[MAX_PATH] was uninitialized: if GetModuleBaseNameW fails (e.g. access denied), the uninitialized buffer would be passed as %ls to _snwprintf_s, reading garbage off the stack until a zero byte. - dump_folder[MAX_PATH] was uninitialized: if both RegGetValueW and SHGetKnownFolderPath fail, the garbage value is passed to CreateDirectoryW and _snwprintf_s. - SHGetKnownFolderPath return value was unchecked: localappdata was an indeterminate pointer on failure, causing undefined behavior (likely a crash) in the _snwprintf_s call that followed. Initialize basename and dump_folder to L"" at declaration, and guard _snwprintf_s behind a SUCCEEDED check on SHGetKnownFolderPath. - skip dump silently if no valid folder can be determined RegGetValueW with ERROR_MORE_DATA leaves the buffer contents undefined, so clear dump_folder[0] at the start of the fallback path to discard any partial write before attempting SHGetKnownFolderPath. Guard all dump-writing code behind dump_folder[0] != L'\0' so that if both the registry lookup and SHGetKnownFolderPath fail, we skip silently rather than proceeding with an empty path and creating a file like \\basename.pid.dmp at the root of the current drive. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
uv_fs_event_start() stores the watched directory path verbatim in handle->dirw. When an event arrives, the child path is resolved to its long form with GetLongPathNameW() and uv__relative_path() strips the handle->dirw prefix off the result. Previously if the directory was supplied as an 8.3 short path, the long form no longer shares that prefix, so the prefix check in uv__relative_path() fails, which either fires an assertion in builds without NDEBUG or produces a wrong(potentially out-of-bounds) result otherwise. This patch falls back to the name reported by ReadDirectoryChangesW in this case, since that is already relative to the watched directory, similar to how other branches handle it. Also update the test to try testing under %TEMP% if accessible to increase the chance of it reproducing in the CI.
Specifically by returning a NULL addr, otherwise `msg_name` might contain bogus data. Observed on `FreeBSD` when issuing a `shutdown()` on a connected udp socket. Signed-off-by: Santiago Gimeno <santiago.gimeno@gmail.com> Fixes: #5161
All CI workflows lacked a top-level permissions block, leaving each run to inherit the repository default (potentially write-all). Each workflow now has `permissions: read-all` at the top level. Every action reference that used a mutable version tag was pinned to its full commit SHA, preventing silent tag-rewriting supply-chain attacks. Verified with zizmor --min-severity high: no findings after this patch. Signed-off-by: Alb3e3 <tomaska.filip@gmail.com>
Specifically on AIX and SunOS.
Bumps [reactivecircus/android-emulator-runner](https://github.com/reactivecircus/android-emulator-runner) from 70f4dee990796918b78d040e3278474bdbd348a7 to e89f39f1abbbd05b1113a29cf4db69e7540cae5a. - [Release notes](https://github.com/reactivecircus/android-emulator-runner/releases) - [Changelog](https://github.com/ReactiveCircus/android-emulator-runner/blob/main/CHANGELOG.md) - [Commits](ReactiveCircus/android-emulator-runner@70f4dee...e89f39f) --- updated-dependencies: - dependency-name: reactivecircus/android-emulator-runner dependency-version: e89f39f1abbbd05b1113a29cf4db69e7540cae5a dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@a309ff8...ece7cb0) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: 6.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
The GH images no longer ship VS2022 in server 2025.
It's unsound to call some of the threading functions after the target thread has terminated. Fixes: #5117
Bumps [reactivecircus/android-emulator-runner](https://github.com/reactivecircus/android-emulator-runner) from 2.37.0 to 2.38.0. - [Release notes](https://github.com/reactivecircus/android-emulator-runner/releases) - [Changelog](https://github.com/ReactiveCircus/android-emulator-runner/blob/main/CHANGELOG.md) - [Commits](ReactiveCircus/android-emulator-runner@e89f39f...a421e43) --- updated-dependencies: - dependency-name: reactivecircus/android-emulator-runner dependency-version: 2.38.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Solaris provides getrandom(2), which is preferred over reading from /dev/urandom directly. Build the shared getrandom backend on SunOS and select it before falling back to /dev/urandom when the symbol is unavailable.
Commit 9f0101d moved error/hangup handling into `uv__poll_io()`. The moved code mixed backend `POLL*` interest bits with `UV_*` callback event bits, producing wrong callback masks. Translate the backend bits before adding them to the callback mask.
Inside a Windows AppContainer, pipes must use the \\.\pipe\LOCAL\ prefix. The API expands LOCAL to include the ID of the AppContainer, so that different apps have different pipe name spaces. Outside AppContainer, the \LOCAL\ is permitted and left unmodified by the APIs. This commit changes the construction of unique pipe names to include \LOCAL when running under AppContainer. It leaves apps outside AppContainer behaving exactly as before. In addition to that very small change, this commit adds a program to start and run a command inside AppContainer and then updates the CI to run the Windows tests both outside of and inside an AppContainer. On i686 we need a newer version of mingw, so update CI runner to ubuntu-26.04 (currently in preview). Fixes #5178
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 6.3.0 to 7.0.0. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@ece7cb0...5fda3b9) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: 7.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.3 to 7.0.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@df4cb1c...9c091bb) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 7.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Integrate write cancellation into uv_cancel(). Cancelling a write request causes its callback to fire with UV_ECANCELED status. A new uv_write_nwritten() helper reports how many bytes were written before cancellation, primarily useful for detecting partial writes. Cancellation semantics by stream type: - TCP / overlapped pipe: CancelIoEx on the overlapped handle. - Non-overlapped pipe: CancelSynchronousIo for the active thread-pool write, or direct queue removal for queued writes. - TTY: No-op (writes complete synchronously on Windows). On Unix, queued writes are moved to the completed queue with UV_ECANCELED. Already-completed writes return 0 from uv_cancel() and their callback reports the original status. A note on the windows pipe file changes: Coalesced (multi-buffer and ipc) pipe writes were issued through a heap-allocated wrapper request, and it was the wrapper's OVERLAPPED - not the caller's - that was submitted to the kernel. This dual-request setup is a leftover: before the coalescing rework (#1843), one logical ipc write was issued as two kernel operations (a frame-header write and a payload write), and the second concurrently-inflight operation needed a second, libuv-owned OVERLAPPED. Coalescing reduced every write to a single WriteFile, so the caller's request - which is guaranteed to outlive the operation, and which TCP and TTY writes submit directly - can carry it. The wrapper's only remaining jobs were locating the merged data buffer to free at completion and locating the caller's request for the callback; the existing write_buffer field covers the former, and submitting the caller's request makes the latter moot. Submit the caller's request itself and heap-allocate only the merged data. Without this change, write cancellation for coalesced writes would be broken: uv__write_cancel() called CancelIoEx() with the caller's OVERLAPPED, which was never submitted, and the resulting ERROR_NOT_FOUND was indistinguishable from the already-completed case - the cancellation was reported as success while the write carried on uncancelled. With only one request per write, cancellation necessarily targets the OVERLAPPED the kernel actually holds. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This optimizes the Unix write request bookkeeping when a write completes the last non-empty buffer but the request still has trailing zero-length buffers. Previously uv__write_req_update() stopped on the first trailing empty buffer, left the write request incomplete, and caused the stream code to arm POLLOUT even though there were no bytes left to write. The fix advances the write index past empty buffers after accounting for the bytes written, so requests whose remaining buffers are all empty complete immediately, without an extra iteration of poll. Refs #5182
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot]
Can you help keep this open source service alive? 💖 Please sponsor : )