Skip to content

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

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

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

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Apr 28, 2021

See Commits and Changes for more details.


Created by pull[bot]

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

bnoordhuis and others added 27 commits December 6, 2024 00:11
io_uring support was default-disabled because of numerous kernel bugs
but those are all in the sqpoll (file i/o) parts of io_uring.

Batching of epoll_ctl calls through io_uring works fine, is a nice
optimization, and is therefore unconditionally enabled again.

The UV_USE_IO_URING environment variable now only affects sqpoll, and
only when the UV_LOOP_ENABLE_IO_URING_SQPOLL event loop flag is set.

Fixes: #4616
It was already documented but only in the uv_timer_set_repeat section.
Move it to the toplevel and flesh it out more.

Refs: #181
Refs: #4639
It was introduced in Vista, so we can assume it's always there now.
The OG MinGW has been dead for years, MinGW-w64 has taken its place.
Replaces: #4504
Fixes: #1980
Fixes: #3267

Co-authored-by: Hüseyin Açacak <huseyin@janeasystems.com>
Co-authored-by: Andrew McGoogan <amcgoogan@cribl.io>
Fixes: nodejs/node#52769
This commit documents a FreeBSD kernel issue where uv_fs_event can
receive a NULL filename and updates test-fs-event.c to skip filename
assertions on FreeBSD.

* Bugzilla: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197695

Refs: #4606

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Shuffle around and DRY the sendmsg logic in preparation for
uv_udp_try_send2(). NFC barring bugs.

This work was sponsored by ISC, the Internet Systems Consortium.
Add a version of uv_udp_try_send that can send multiple datagrams.

Uses sendmmsg(2) on platforms that support it (Linux, FreeBSD, macOS),
falls back to a regular sendmsg(2) loop elsewhere.

This work was sponsored by ISC, the Internet Systems Consortium.
Replace comparison of `alloc_cb_called` with the total bytes
read (`bytes_read`) to validate the test's correctness.

Fixes: #4650
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
This patch will update Android API in CI to 29 and will set up the fdsan
in the test runner.

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Fixes: #4369
Fixes: #4651

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Refs: #3119

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Co-authored-by: James M Snell <jasnell@gmail.com>
Changes since version 1.49.2:

* ci: run macOS and iOS tests also on macOS 14 (Saúl Ibarra Corretgé)

* unix,win: map ENOEXEC errno (Saúl Ibarra Corretgé)

* test: skip multicast join test on ENOEXEC (Saúl Ibarra Corretgé)

* ci: make sure the macOS firewall is disabled (Saúl Ibarra Corretgé)

* darwin,test: squelch EBUSY error on multicast join (Saúl Ibarra
  Corretgé)

* build: update minimum cmake to 3.10 (Ben Noordhuis)

* kqueue: use EVFILT_USER for async if available (Jameson Nash)

* unix,win: fix off-by-one in uv_wtf8_to_utf16() (Ben Noordhuis)

* doc: add scala-native-loop to LINKS.md (Julian A Avar C)

* unix: fix build breakage on haiku, openbsd, etc (Jeffrey H. Johnson)

* kqueue: lower overhead in uv__io_check_fd (Andy Pan)

* doc: move cjihrig back to active maintainers (cjihrig)

* build(deps): bump actions/checkout from 3 to 4 (dependabot[bot])

* unix,pipe: fix handling null buffer in uv_pipe_get{sock,peer}name
  (Saúl Ibarra Corretgé)

* unix,win: harmonize buffer checking (Saúl Ibarra Corretgé)

* unix,win: add support for detached threads (Juan José Arboleda)

* src: add uv_thread_set/getname() methods (Santiago Gimeno)

* build: fix qemu builds (Ben Noordhuis)

* win: drop support for windows 8 (Ben Noordhuis)

* linux: fix uv_cpu_info() arm cpu model detection (Ben Noordhuis)

* linux: always use io_uring for epoll batching (Ben Noordhuis)

* doc: clarify repeating timer behavior more (Ben Noordhuis)

* unix,win: handle nbufs=0 in uv_udp_try_send (Ben Noordhuis)

* win: use GetQueuedCompletionStatusEx directly (Saúl Ibarra Corretgé)

* win: enable uv_thread_{get,set}name on MinGW (Saúl Ibarra Corretgé)

* win: drop support for the legacy MinGW (Saúl Ibarra Corretgé)

* win,fs: get (most) fstat when no permission (Jameson Nash)

* win: plug uv_fs_event_start memory leak (amcgoogan)

* test: address FreeBSD kernel bug causing NULL path in fsevents (Juan
  José Arboleda)

* unix: refactor udp sendmsg code (Ben Noordhuis)

* unix,win: add uv_udp_try_send2 (Ben Noordhuis)

* test: fix flaky flaky udp_mmsg test (Juan José Arboleda)

* build: enable fdsan in Android (Juan José Arboleda)

* test: fix udp-multicast-join for FreeBSD (Juan José Arboleda)

* win: fix leak processing fs event (Saúl Ibarra Corretgé)

* src: set a default thread name for workers (Rafael Gonzaga)

* misc: implement uv_getrusage_thread (Juan José Arboleda)
Said symbols are not by default available on Windows Server 2016 but
libuv can still use them when
api-ms-win-core-processthreads-l1-1-3.dll is present.

Fixes: #4677
The CreateProcess API on Windows is still not longPathAware,
even if the process itself is. So, if the cwd used for CreateProcess
is too long, then the call fails with a 'INVALID_DIRECTORY' error.

To deal with this, check the length of the cwd and shorten it if it
is longer than MAX_PATH.
vtjnash and others added 30 commits March 19, 2026 15:28
Previously, the user might unknowingly close a uv_process_t before
doing waitpid on the zombie, leaving it forever undead. Track the state
of the child, so that the application wrapper can avoid this by calling
uv_process_kill and checking for UV_ESRCH error.
The fcntl cannot fail at this point but let's check the return code
anyway, just in case.

Fixes: #5080
The function is only used on BSDs. Introduced in commit 919b92d ("unix:
support long path names in pipe.c") from a few days ago.
The documentation already stated that the receive buffer should be
a multiple of 64 KiB when the UV_UDP_RECVMMSG is used, but make that
more prominent in the documentation and enforce it in the code.

Refs: https://github.com/libuv/libuv/security/advisories/GHSA-r846-fxvr-f3rx
Because libuv truncates the result of every call to INT32_MAX, it needs
to internally limit operations to INT32_MAX to be safe to use libuv.
This isn't an API change, since these operations weren't guaranteed to
work, and in fact usually failed in bizare ways already. This is very
long in coming, since we've had a lot of compiler warnings about this
and several PRs to fix this open for a decade, but the main consumers
that usually fix things didn't care (nodejs is 32-bit and julia patched
this downstream more than a decade ago, though it did run into this
again recently by mistake with sendfile).

Replaces #1501
Fixes #3360
Copy the optimization from tcp/udp stack: when read/writes don't require
IOCP to complete, put them directly right into the pending queue, so
they can be processed without a full loop through IOCP each time to
drain them asynchronously.
Remove the conditionals so that posix_spawn will be used whenever
possible, and not only on Apple.

Tests specifically if posix_spawn works before using it: it is broken
on QEMU with glibc, for example, since fork/clone is broken there.
Fixes a -Wincompatible-pointer-types error on Windows, since uv_os_fd_t
is not int but HANDLE.
The project has been getting a flood of private vulnerability reports, most of which are invalid, and a few of which should have just been normal bugs. This has essentially been a DoS attack on maintainer time, since we're unable to change them into normal bugs after assessment. We now have a libuv-security@googlegroups.com list instead to help redirect those seeking CVE fame. The hope is to redirect most people to actually use the issue list as it has always been intended to be used.
Otherwise calling `RtlGetVersion()` might produce UB. Problem was
causing random crashes in the node.js test suite with stack traces like
this one:
```
node.exe!__report_gsfailure(unsigned __int64 stack_cookie) Line 220
	at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\gs\gs_report.c(220)
node.exe!uv__tcp_keepalive(uv_tcp_s * socket, unsigned __int64 on, int idle, unsigned int intvl, unsigned int cnt, unsigned int) Line 109
	at E:\node\deps\uv\src\win\tcp.c(109)
[Inline Frame] node.exe!uv_tcp_keepalive_ex(uv_tcp_s * handle, int on, unsigned int idle, unsigned int intvl, unsigned int cnt) Line 1406
	at E:\node\deps\uv\src\win\tcp.c(1406)
node.exe!uv_tcp_keepalive(uv_tcp_s * handle, int on, unsigned int idle) Line 1395
	at E:\node\deps\uv\src\win\tcp.c(1395)
node.exe!node::TCPWrap::SetKeepAlive(const v8::FunctionCallbackInfo<v8::Value> & args) Line 213
	at E:\node\src\tcp_wrap.cc(213)
[External Code]
node.exe!v8::internal::`anonymous namespace'::Invoke(v8::internal::Isolate * isolate, const v8::internal::`anonymous namespace'::InvokeParams & params) Line 463
	at E:\node\deps\v8\src\execution\execution.cc(463)
node.exe!v8::internal::Execution::Call(v8::internal::Isolate * isolate, v8::internal::DirectHandle<v8::internal::Object> callable, v8::internal::DirectHandle<v8::internal::Object> receiver, v8::base::Vector<const v8::internal::DirectHandle<v8::internal::Object>> args) Line 532
	at E:\node\deps\v8\src\execution\execution.cc(532)
node.exe!v8::Function::Call(v8::Isolate * isolate, v8::Local<v8::Context> context, v8::Local<v8::Value> recv, int argc, v8::Local<v8::Value> * argv) Line 5374
	at E:\node\deps\v8\src\api\api.cc(5374)
node.exe!v8::Function::Call(v8::Local<v8::Context> context, v8::Local<v8::Value> recv, int argc, v8::Local<v8::Value> * argv) Line 5381
	at E:\node\deps\v8\src\api\api.cc(5381)
node.exe!node::InternalMakeCallback(node::Environment * env, v8::Local<v8::Object> resource, v8::Local<v8::Object> recv, const v8::Local<v8::Function> callback, int argc, v8::Local<v8::Value> * argv, node::async_context asyncContext, v8::Local<v8::Value> context_frame) Line 257
	at E:\node\src\api\callback.cc(257)
node.exe!node::AsyncWrap::MakeCallback(const v8::Local<v8::Function> cb, int argc, v8::Local<v8::Value> * argv) Line 695
	at E:\node\src\async_wrap.cc(695)
[Inline Frame] node.exe!node::AsyncWrap::MakeCallback(const v8::Local<v8::Name> symbol, int argc, v8::Local<v8::Value> * argv) Line 101
	at E:\node\src\async_wrap-inl.h(101)
[Inline Frame] node.exe!node::AsyncWrap::MakeCallback(const v8::Local<v8::String> symbol, int argc, v8::Local<v8::Value> * argv) Line 78
	at E:\node\src\async_wrap-inl.h(78)
node.exe!node::ConnectionWrap<node::TCPWrap,uv_tcp_s>::OnConnection(uv_stream_s * handle, int status) Line 73
	at E:\node\src\connection_wrap.cc(73)
node.exe!uv__process_tcp_accept_req(uv_loop_s * loop, uv_tcp_s * handle, uv_req_s * raw_req) Line 1245
	at E:\node\deps\uv\src\win\tcp.c(1245)
node.exe!uv__process_reqs(uv_loop_s * loop) Line 622
	at E:\node\deps\uv\src\win\core.c(622)
node.exe!uv_run(uv_loop_s * loop, <unnamed-tag> mode) Line 736
	at E:\node\deps\uv\src\win\core.c(736)
node.exe!node::SpinEventLoopInternal(node::Environment * env) Line 43
	at E:\node\src\api\embed_helpers.cc(43)
[Inline Frame] node.exe!node::NodeMainInstance::Run(node::ExitCode * exit_code, node::Environment * env) Line 109
	at E:\node\src\node_main_instance.cc(109)
node.exe!node::NodeMainInstance::Run() Line 99
	at E:\node\src\node_main_instance.cc(99)
[Inline Frame] node.exe!node::StartInternal(int argc, char * * argv) Line 1576
	at E:\node\src\node.cc(1576)
node.exe!node::Start(int argc, char * * argv) Line 1583
	at E:\node\src\node.cc(1583)
node.exe!wmain(int argc, wchar_t * * wargv) Line 91
	at E:\node\src\node_main.cc(91)
```

Fixes: #5106
When uv__stream_open() fails inside uv_accept(), the accepted fd is
closed but POLLIN is never re-enabled on the server's IO watcher.
The condition `if (err == 0)` prevents uv__io_start() from being
called on the error path, causing the server to permanently stop
accepting new connections.

Fix by removing the err == 0 guard so POLLIN is re-enabled
unconditionally when no queued fds are present.
Fixes: #5083
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Fixes: #5086
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
futimens() may fail with EPERM on CIFS/SMB shares that do not
support setting timestamps. Since preserving timestamps during
copyfile is best-effort, ignore the return value unconditionally.

Fixes: nodejs/node#56248
Refs: #4396
Fix undeclared identifiers and use fork instead of posix_spawn on AIX/PASE.

Co-authored-by: Korinne Adler <kadler@us.ibm.com>
Co-authored-by: chenyuebiao <chenyuebiao@bytedance.com>
Use STARTUPINFOEXW with PROC_THREAD_ATTRIBUTE_HANDLE_LIST so that only
the stdio handles prepared for each child process are inherited by it.
This closes the race condition where two concurrent uv_spawn calls
could cause handles intended for one child to leak into another child process.

Fixes: #1490
Closes: #3856

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Stop `uv__udp_recvmmsg()` from emitting its own callback when
`recvmmsg()` returns `<= 0`, since this duplicates the handing in
`uv__udp_recvmsg()` which emits the same callback again.

Add a regression test that keeps the socket open past
`UV_UDP_MMSG_FREE` and fails on a second terminal callback.

Co-authored-by: Isaac Elbaz <587490+script3r@users.noreply.github.com>
Fixes one of the regressions listed in #2076

Co-authored-by: sturcottelangevin <sturcottelangevin@bhvr.com>
Refactor uv__kqueue_init to use a temporary fd variable and properly
handle errors from uv__cloexec. If setting CLOEXEC fails, close the
kqueue fd and return the error instead of leaking the descriptor.

Fixes: #5081
Replace `UV_HANDLE_READING` flag checks with `stream->read_cb != NULL`
on the Unix side, removing redundant state management.

Refs: #4995
Replace the hard-coded IPv6 address buffer size in `uv_ip6_addr()` with
`INET6_ADDRSTRLEN` to avoid truncation.

`INET6_ADDRSTRLEN` is the standard constant for the maximum length of
an IPv6 address string representation. Using it makes the intent of the
buffer clearer and avoids relying on a magic number.

This is **not** a security fix. The existing code already bounds
`address_part_size` before calling `memcpy()`, so the previous
implementation did not expose a buffer overflow.
Guard `udp_recvmsg_unreachable_error6` in case ipv6 is not supported.

Fixes: #5143
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.