Skip to content

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

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

pull[bot] wants to merge 1045 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 : )

GangZhuo and others added 27 commits November 18, 2025 20:45
When `wtf8_ptr` is NULL, the length will be stored in `wtf8_len_ptr` (not in `wtf8_ptr`).

Fixes: #4934
---------

Signed-off-by: Andy Pan <i@andypan.me>
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v5...v6)

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

Signed-off-by: dependabot[bot] <support@github.com>
Fetch file metadata by handle instead of by path, otherwise there is a
race window between fetching and acting on said metadata where another
process can replace the file with another one.

There is still a potential race when upgrading the short path to a long
path but that that one is intrinsic. It's not something libuv can solve
except by refraining from calling GetLongPathName.

Fixes: #4568
Remove the microsecond truncation in uv__fs_to_timespec() function to enable
full nanosecond resolution support. The utimensat() system call already
supports nanosecond precision, so the artificial truncation to microseconds
is no longer necessary.

This allows file modification and access times to be set with full nanosecond
precision instead of being limited to microsecond resolution.

Fixes the TODO comment about removing the microsecond resolution limit.
The initial FindFirstFile can fail with ERROR_FILE_NOT_FOUND, meaning
no matches (read: empty directory), which leaves dir_handle set to
INVALID_HANDLE_VALUE. Not an actual error, it just means no results.

I can't get FindFirstFile to work like that on regular file systems
but it's been reported that it does under sshfs-win and the MSDN
documentation clearly states it's possible. Handle it.

Fixes: #4952
Added `TEST_FS_DECLARE`, `TEST_FS_ENTRY` and `TEST_FS_IMPL` so we can
run test-fs.c tests both using the threadpool and io_uring
implementations.
The `offset` field should be assigned to ithe `io_uring_sqe.off` field.
Add macos-15 runners. Remove the deprecated macos-13 runners.

Fixes: #4965
Refs: actions/runner-images#10924
And fix a stupid typo that made GHA skip running the tests 🤦
Use GetFileInformationByHandleEx(FileBasicInfo) instead of GetFileInformationByHandle() because it's cheaper -- one syscall, instead of two [1]

[1]: https://blog.axiorema.com/engineering/hidden-cost-getfileinformationbyhandle/
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v6...v7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fix `threadpool_cancel_fs_iouring` so it takes `UV_FS_FTRUNCATE` into
account.
If uv_spawn() fails after uv__handle_init() has been called, the handle
remains in loop->handle_queue. This causes use-after-free if the handle
is stack-allocated or freed, and a subsequent loop operation like
uv_walk() accesses it.

This follows the same pattern as uv_tcp_init_ex() which explicitly
removes the handle from the queue on error.
As of January 1, 2026, HP-UX is well and truly dead. Remove it.
Zero the struct. The compiler is not aware it's not actually used.
Check the length before doing the compare like we do a few lines below,
not the other way around. It's a false positive because the length is
capped well below the maximum object size but it's an easy fix.

Fixes the following warning:

    test/test-poll-oob.c:94:19: warning: ‘strncmp’ specified bound
    [18446744071562067968, 18446744073709551615] exceeds maximum
    object size 9223372036854775807 [-Wstringop-overread]
AddressSanitizer was right to complain about the test because it was
passing an uninitialized `struct winsize` to openpty().
This adds support for "Linux"-style Windows symbolic links, reparse tag
0xA000001D (IO_REPARSE_TAG_LX_SYMLINK).
It was reported that PTYs on Linux sometimes report POLLHUP, return a
partial read, but still return more data on the next read.

Libuv contains an optimization where it assumes a partial read after
POLLHUP means the next read can be skipped because it's going to fail
with EOF anyway. That assumption was thought to be always true but,
alas, it isn't.

The fact the optimization has been present for 13 years and this is the
first bug report about it, indicates how rare this particular condition
is, but of course we can't skim on correctness.

The reworked optimization only uses POLLHUP as an input signal when
POLLIN is not also set. That means we no longer have to track partial
reads because we're going to try and read anyway as long as POLLIN is
set. It seems to cause no measurable regressions on the test suite or
the (lightly tested) benchmarks.

Fixes: #4992
bnoordhuis and others added 18 commits October 21, 2026 19:00
It was reported that AIX and IBM i lack these system calls.
z/OS doesn't seem to have them either so let's be proactive.

Refs: #5357 (comment)
uv_spawn() removed the handle from loop->handle_queue on error and
uv_close() removed it again. uv__queue_remove() doesn't reset the
handle's links, so the second call clobbers whatever they point to.

uv_close() must be called after a failed uv_spawn() anyway, so leave
the handle in the queue and let uv_close() remove it.

Refs: #4980
Not doing so is bug prone: calling uv__queue_remove twice on the same
queue corrupts whatever it's pointing at.

Refs: #5352
Allow applications to skip LaunchServices registration and display name
updates by setting UV_PROCESS_TITLE_USE_LAUNCH_SERVICES=0 at startup
Keep the default enabled to preserve Activity Monitor behavior.

Capture the setting in uv_setup_args so concurrent title updates do not
read the environment, and retain argv updates and thread naming when
LaunchServices is disabled.

Add regression coverage for value parsing, repeated updates and setting
changes after initialization, and document the opt-out.

Fixes: #5300
Bumps [vmactions/openbsd-vm](https://github.com/vmactions/openbsd-vm) from 1.4.8 to 1.4.9.
- [Release notes](https://github.com/vmactions/openbsd-vm/releases)
- [Commits](vmactions/openbsd-vm@5f7b2c9...f1ca8bc)

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

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [vmactions/solaris-vm](https://github.com/vmactions/solaris-vm) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/vmactions/solaris-vm/releases)
- [Commits](vmactions/solaris-vm@87d3c43...1c16697)

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

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 7.0.0 to 7.1.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@5fda3b9...6d4fd22)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 7.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
The test wants to write more data than fits in the kernel's backing
buffer. Linux's default buffer size is 16 times the page size.

For most systems that works out to 16 x 4 KiB = 64 KiB, but on
architectures with 64 KiB pages, 16 x 64 KiB = 1 MiB, which was
exactly the size of the data we wrote. Easy fix: double it.

Fixes: #5310
v1.0.0 was released 12 years ago. It's probably safe to assume that
anyone who still hasn't upgraded in that time frame, never will.
FreeRTOS is closer to an operating system toolkit than a true operating
system. There is a lot that isn't supported out of the box, or at all.

I've implemented what can be reasonably implemented and left out what
cannot: networking, file I/O, things like that. It successfully builds
and runs on an ARM Cortex-M3 board.

This is a large commit but the meat is confined to src/rtos/freertos.c
and I don't expect anyone to read every last line of that.

Large parts of the remainder of the diff are me moving functionality
that has no equivalent on FreeRTOS into separate files.
Preallocate a 15 KiB buffer for GetAdaptersAddresses, following
Microsoft's recommendation to use an initial buffer of about 15 KB.
This avoids the initial size query when the data fits.

Co-authored-by: yangzuohui <yangzuohui@bytedance.com>
Refs: https://learn.microsoft.com/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses
uv_poll_init_socket() currently registers the poll handle
before querying socket protocol information.

If getsockopt() fails, the handle remains registered in
the loop even though initialization returns an error.

Move handle initialization after the protocol query so
that failures leave the event loop unchanged.
uv__process_title_cleanup() was empty on Windows, so
uv_library_shutdown() left the cached process title allocated and
never deleted the critical section that guards it.

Free the title and delete the critical section. Only delete it if
uv__util_init() ran, because uv_library_shutdown() can be called
before libuv has been initialized.

Fixes: #3191
uv__get_cgroupv2_constrained_cpu() read cpu.max into a 16 byte buffer,
so uv__slurp() kept at most 15 characters. A line like
"15840000 1000000" lost the last digit of the period, the computed
quota came out ten times too large and uv_available_parallelism()
ignored the cgroup limit. That happens with a 1s period and a quota of
10 or more CPUs.

Read cpu.max into the existing 1024 byte buffer instead.

Fixes: #5374
Refs: #4746
Bug introduced in commit a939d64 from July 2023 although the real
bug is arguably software that maps an empty file at /proc/stat.

Fixes: #5410
uv_getrusage() and uv_getrusage_thread() ran the CPU time from
GetProcessTimes() and GetThreadTimes() through FileTimeToSystemTime()
and added up wHour, wMinute and wSecond. That function treats the value
as a date, so anything past 24 hours moved into wDay and got dropped:
25 hours of CPU time read as 1 hour. A busy process on a machine with
many cores gets there within hours, and the reported time then jumps
backwards.

Compute the seconds and microseconds from the FILETIME ticks instead.
This also stops rounding tv_usec to whole milliseconds.
Bumps [vmactions/netbsd-vm](https://github.com/vmactions/netbsd-vm) from 1.5.2 to 1.5.3.
- [Release notes](https://github.com/vmactions/netbsd-vm/releases)
- [Commits](vmactions/netbsd-vm@c8a0d7d...5957cf3)

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

Signed-off-by: dependabot[bot] <support@github.com>
uv__malloc leaves the three reserved f_spare words uninitialized
after every named field is filled in. The docs say unsupported
fields are set to zero, so clear them before returning the result.

Fixes: #5421
maschwenk and others added 11 commits November 12, 2026 21:46
A forked child that never queues work still has the parent's thread
count, so uv_library_shutdown(), which also runs as a destructor at
exit(), joins worker threads that only exist in the parent. The child
segfaults in pthread_join() with glibc 2.39 and aborts on macOS, where
the join fails.

reset_once(), the pthread_atfork() child handler, already makes the
next uv__work_submit() start a new pool. Also zero the thread count
and the idle and slow I/O counters there, so that
uv__threadpool_cleanup() has nothing to join and init_threads() starts
from zero.

Refs: #4443
Refs: #1269
Fixes: #5422
Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
Don't reject the buffer if it's large enough after trimming the trailing
slash.

Signed-off-by: huangwenbin <huangwenbin@kylinos.cn>
`#include "FreeRTOS.h"` ended up finding the freertos.h header itself on
case-insensitive file systems.
Signed-off-by: huangwenbin <huangwenbin@kylinos.cn>
copy_file_range(2) only works with regular files. Try sendfile(2) if
the former fails with EINVAL.

Fixes: #5440
uv_fs_copyfile() gives the destination the source's access and
modification times with futimens(), but it does that before the data
is copied. The writes that follow update the modification time again,
so the copy ends up with the time of the copy as its mtime instead of
the source's.

Call futimens() after the data has been copied, and also after a
successful FICLONE clone.

Refs: #4396
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
Commit 2f82750 ("unix: match kqueue and epoll code") from July 2023
introduced a regression where uv__io_poll would return too early.

Specifically, libuv tracks time with CLOCK_MONOTONIC_COARSE but inside
epoll_pwait() the kernel uses a higher-precision clock, meaning libuv's
idea of "now" is sometimes lagging the kernel's by a miniscule amount.

That by itself is not a bug (plus, it's inherent when working with
multiple clock domains) but the early return that commit 2f82750
adds makes it observable.

Long story short, when epoll_pwait() returns zero, it's not safe to
assume it's okay to return. Poll again until the timeout expires.

Fixes flaky test closed_fd_events. You need to be somewhat unlucky to
hit this particular condition and that is why it only showed up on the
asan and qemu buildbots, because they're slow.

Fixes: #4767
Cache symbol lookups. We've done that before but back then, it broke
stuff. Now however, it should Just Work(TM) because things have changed.

The history:

- first attempt in 00c6b16 from November 2018

- revert in 97e86dd from Augustus 2019 because it broke node.js

- second attempt in 038eacf from October 2019

- revert in 565cdd1 from December 2019 because reportedly
  changing the process title broke CGDisplayPixelsWide() and
  CGDisplayPixelsHigh()...

However, there is good reason to believe 6e3e422 from January 2020
resolves that problem. The commit log explains why, and also why the
second revert didn't really fix anything: there was no regression,
the second attempt merely made a pre-existing bug in Apple's libraries
more visible.

Now that we no longer call SetApplicationIsDaemon(), it should be safe
to cache looked-up symbols, and doing so makes it about 10x faster.

Should fix test process_title_threadsafe that's flaky under
ThreadSanitizer, not because it's buggy but because all the loading
and unloading of libraries slowed everything down.

Fixes: #5445
The old baseline was RHEL 7 but that distro has been out of support
since July 2024. Move to RHEL 8.

(I'm not counting extended support. People who pay RedHat for that are
never going to upgrade libuv anyway. If they really want to, they can
get in touch with me. My rates are more reasonable than RedHat's.)
3.9 is apparently no longer available. 3.14 should be.
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.