Skip to content

[pull] v1.x from libuv:v1.x - #190

Open
pull[bot] wants to merge 944 commits into
bazelregistry:v1.xfrom
libuv:v1.x
Open

[pull] v1.x from libuv:v1.x#190
pull[bot] wants to merge 944 commits into
bazelregistry:v1.xfrom
libuv:v1.x

Conversation

@pull

@pull pull Bot commented Apr 28, 2021

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

alls0rts and others added 27 commits February 27, 2025 12:24
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>
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.
I changed the default stack size in commit 73b0c1f from October 2022
and although I added a versionchanged note, I didn't update the blurb
a few lines below.

It wasn't accurate before that change either though, because even with
musl libc's ~80kb thread stacks, 128 threads works out to 10 MB.

Refs: nodejs/node#57911
Handle out-of-memory conditions in uv_loop_init better, albeit still
not perfect: bubble up the error instead of aborting.

Also fixes a file descriptor leak on Linux (and likely other platforms)
that the new test caught; the backend epoll fd was being leaked in the
error path.

Fixes: #4755
Distinguish a callback for v4 and v6 connections is not relevant for
this test.

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Fixes: #4659
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Align CPU quota calculation with Rust's cgroup heuristics.

Fixes: #4740
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Propagate errors from uv__io_init_start() back to the caller.

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Propagate errors from uv__io_init_start() back to the caller.

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Changes since version 1.50.0:

* win: fix leak in uv_os_tmpdir (Saúl Ibarra Corretgé)

* docs: fix RTD build (Saúl Ibarra Corretgé)

* win: lazy-load [GS]etThreadDescription symbols (Ben Noordhuis)

* linux: try preadv64/pwritev64 before preadv/pwritev (Ben Noordhuis)

* win: check cwd length before spawning a child process (Morten
  Engelhardt Olsen)

* macos,bsd: handle missing /dev/null in chroot env (Andrey)

* doc: fix README link text (Julio Jordán)

* win: fix order of FILE_STAT_BASIC_INFORMATION struct fields (Hüseyin
  Açacak)

* macos: increase child process stdio buffer size (Jinho Jang)

* doc: add C3 bindings to LINKS.md (Velikiy Kirill)

* unix: remove unnecessary errno.h include in poll.c (Juan José
  Arboleda)

* win: fix the inconsistency in volume serial number (Hüseyin Açacak)

* unix: add thread affinity support on openharmony (rainlow)

* unix: enable getrusage for SunOS (Paolo Insogna)

* unix,win: accept NAN/INFINITY as file timestamps (Ben Noordhuis)

* win: add ENABLE_VIRTUAL_TERMINAL_INPUT raw tty mode (Anna Henningsen)

* test: handle UV_ENOTSUP in platform_output (cjihrig)

* doc: fix rendering of threading.html (Tobias Nießen)

* unix,sunos: enable use of sendmmsg on Solaris and Illumos (Stacey
  Marshall)

* unix: handle out of memory in iface name copy (Ben Noordhuis)

* openbsd: do not error out if cpuspeed is not available (Robert Nagy)

* test: skip thread_name_threadpool on AIX/IBMi (Abdirahim Musse)

* aix,ibmi: fix undeclared identifiers (Richard Lau)

* unix,sunos: prefer SO_REUSEPORT for load balancing (Stacey Marshall)

* doc: free lib pointer before function return (mugitya03)

* test: link with libm (Juan José Arboleda)

* style: rename parameter to match definition (Mohammed Keyvanzadeh)

* test: support partial output lines in test runner (cjihrig)

* build: switch from c90 to c11 (Ben Noordhuis)

* linux: allow nul bytes in abstract socket address (Itay Bookstein)

* sunos: use pipe2 on solaris and illumos (Andy Pan)

* unix: remove TOCTOU issues from uv_pipe_chmod (Ben Noordhuis)

* unix: use pipe_fname if getsockname returns nothing (crupest)

* haiku: use uint32 instead of uint32_t (AE1020)

* doc: update thread pool stack size comment (Ben Noordhuis)

* unix: improve uv_loop_init OOM handling (Ben Noordhuis)

* test: merge uv_tcp_connect callbacks (Juan José Arboleda)

* test: skip multievent tests on macOS with TSAN enabled (Juan José
  Arboleda)

* linux: align CPU quota calculation with Rust (Juan José Arboleda)

* kqueue: improve fs event watcher OOM handling (Juan José Arboleda)

* sunos: improve fs event watcher OOM handling (Juan José Arboleda)

* build: shorten instructions for cmake build (Juan José Arboleda)
Alb3e3 and others added 30 commits June 14, 2026 12:47
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
Closing a stream already cancels its outstanding writes. Treat a later
uv_cancel() for one of those requests as a no-op instead of feeding the
closed stream I/O watcher, which asserts on Unix.

Note this also applies to writes that had already completed, which are
otherwise documented to be a successful no-op to cancel.

Fixes: #5205
`fs_null_req` and `fs_get_system_error` pass a NULL loop and a NULL
callback to every `uv_fs_*` call they make, so they are purely
synchronous and never touch an event loop. `TEST_FS_IMPL` exists to
re-run a test with `io_uring` enabled, which for these two means running
the identical synchronous code a second time.

The duplicate is not merely redundant: the generated wrapper calls
`uv_loop_configure(uv_default_loop(), ...)`, so it creates a default
loop that the test body then has to close and partly defeats the intent
of the test (to ensure these functions work without a call to setup the
`uv_default_loop()` existing first).

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Both tests run the default loop and return without closing it making
valgrind potentially unhappy.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
On some modern AMD CPUs (EPYC, Ryzen), every read of `scaling_cur_freq`
makes the ACPI cpufreq driver do a slow round-trip through SMM, costing
~20ms per core ΓÇö amplified inside containers. On a 32-core EPYC this
makes a single `uv_cpu_info()` call take 500ΓÇô600ms. I reported this
against Node.js in nodejs/node#61998, with an
strace showing the individual `scaling_cur_freq` reads each taking
~20ms.

The reported speed now reflects the max frequency the governor currently
allows rather than a point-in-time sample - the trade-off discussed and
accepted in #5036. This seems like the simplest solution, but we could
implement a fallback-type solution as per #5036 if preferred.

Takes over #5036, which has stalled. Implements the `scaling_max_freq`
approach suggested in that thread.

Fixes: #4098
Fixes: #5110
Refs: nodejs/node#61998
Closes: #5036
Co-authored-by: RajeshKumar11 <22585507+rajeshkumar11@users.noreply.github.com>
Fix the Solaris build when <paths.h> does not define _PATH_DEFPATH,
and initialize the event-loop timeout to silence a Solaris compiler
warning.

Fix the Solaris fs_event_watch_delete_dir test crash by accepting NULL
filenames from the fs-event callback; the backend uses NULL when it
cannot determine a name.

Run the Solaris tests as a temporary non-root user. Make the checked-out
tree owned by that user so fs_copyfile compares matching source and
destination group IDs. Keep the workflow dependency-free because the
Solaris VM image already includes the required build tools, and trigger
it for the solaris branch as well as the usual branches.
Keep accepting NULL filenames from fs event callbacks, but use
ASSERT_STR_EQ for non-NULL values so failures report the actual and
expected filenames.
Bumps [vmactions/solaris-vm](https://github.com/vmactions/solaris-vm) from 1.3.7 to 1.3.8.
- [Release notes](https://github.com/vmactions/solaris-vm/releases)
- [Commits](vmactions/solaris-vm@d30dd6c...315163f)

---
updated-dependencies:
- dependency-name: vmactions/solaris-vm
  dependency-version: 1.3.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.3 to 7.0.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v6.0.3...3d3c42e)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
uv_pipe_pending_instances() sets the UV_HANDLE_PIPESERVER flag before the
pipe is bound. When the subsequent bind fails, e.g. with UV_EADDRINUSE
after losing a bind race on a well-known pipe name, uv_pipe_bind2() frees
accept_reqs and resets it to NULL, but the flag stays set. Closing the
handle then dereferences the NULL accept_reqs array in uv__pipe_close()
(release builds crash with an access violation; debug builds trip the
assert in uv__pipe_endgame()).

Tolerate accept_reqs == NULL at both cleanup sites.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.