Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 713 commits into
base: v1.x
Choose a base branch
from
Open

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

wants to merge 713 commits into from

Conversation

pull[bot]
Copy link

@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 : )

sgallagher and others added 28 commits November 14, 2023 10:23
Passing this to uv__is_ipv6_link_local() is causing a segmentation
fault. Note that the documentation for getifaddrs() explicitly states
that this value may be NULL.

Signed-off-by: Stephen Gallagher <[email protected]>
Add uv_thread_setpriority for setting priority for threads created by
uv_thread_create. Add uv_thread_getpriority for getting thread priority.

For Linux by default, if the scheduling policy is SCHED_OTHER and the
priority is 0, we need to set the nice value.

Fixes: #4051
This was incorrectly dropped by #4030, where previously connecting to ""
might fail eventually, now instead it would return EINVAL and then fail
to initialize the struct or call the callback.
There is no length at which this gets truncated on Windows. The
underlying file system will just not successfully connect to a longer
path (in WTF-16 characters), which will return an error asynchronously
with the existing API.

Refs: #4040
First kernel with support is 6.1, was only fully functional from .51
onwards: https://lore.kernel.org/all/[email protected]/

Co-authored-by: matoro <[email protected]>
Passing a socket name without a trailing nul byte to uv_pipe_bind2() or
(on Windows) uv_pipe_connect2() resulted in reading beyond the end of
the name buffer when copying or converting it.

Fix that by copying the socket name to temporary storage first and add
the trailing nul byte explicitly.

Add a check for embedded nul bytes in the socket name.

Fix a small memory leak in the Windows error path of uv_pipe_bind2().
AIX does not implement ifaddrs and when retrieving the network
interfaces with uv_interface_addresses there was a test failure in
tcp_connect6_link_local.

For now disable ipv6 link local on aix to:

1) fix broken aix build
2) stop blocking libuv upgrade in node

Refs: #4222 (comment)
Refs: nodejs/node#50650
On Fedora's build system, the build environment runs on btrfs. This
revealed a bug in the test on i686 systems, where this comparison was
being performed as a comparison of two signed integers, but the
filesystem type of btrfs happens to use the higher-order bits, resulting
in it appearing as a negative value.

BTRFS_SUPER_MAGIC     0x9123683e

Signed-off-by: Stephen Gallagher <[email protected]>
w_target_len is set but unsued in release mode.
Introduced long ago for old Linux/libc flavors libuv no longer supports.

We include <ifaddrs.h> unconditionally elsewhere so there is no point in
special-casing it here.

Fixes: #4242
On IBM i this test fails asserting the write queue size.
The test expects the queue size to be greater than 0 but
the queue size is 0 on IBM i.

https://github.com/libuv/libuv/blob/66160d6973b41040f6b2066a84359147258f60c3/test/test-tcp-write-in-a-row.c#L75

The test expects the write to get queued because the size of the data
is larger than the send and receive buffers.

https://github.com/libuv/libuv/blob/66160d6973b41040f6b2066a84359147258f60c3/test/test-tcp-write-in-a-row.c#L39-L40

For some reason the request does not seem to get queued on IBM i.
The root cause of the issue will need further investigation.

Part of #4143
Calling `uv_timer_start(h, cb, 0, 0)` from a timer callback resulted in
the timer running immediately because it was inserted at the front of
the timer heap.

If the callback did that every time, libuv would effectively busy-loop
in `uv__run_timers()` and never make forward progress.

Work around that by collecting all expired timers into a queue and only
running their callback afterwards.

Fixes: #4245
Co-authored-by: Ben Noordhuis <[email protected]>
AIX and IBM i don't have getifaddrs but we do have code in
`uv_interface_addresses` to get the interface addresses.

Refs: #4117
The `\0` character has no special significance in abstract sockets, so
the addrlen field in both `bind()` and `connect()` should take that into
account.
The clangd index, before creating the `compile_commands.json` file will
create the indexes under a `.cache` folder. This does not need to be
tracked by the repo.

Signed-off-by: Juan José Arboleda <[email protected]>
Solaris claimed it supported the TCP-Alives mechanism,
but TCP_KEEPIDLE, TCP_KEEPINTVL, and TCP_KEEPCNT were not
available on Solaris until the latest version 11.4.
Therefore, we need to simulate the TCP-Alives mechanism on
other platforms via TCP_KEEPALIVE_THRESHOLD + TCP_KEEPALIVE_ABORT_THRESHOLD.
The new F_KINFO flag does not seem to work with directories nor with
deleted entries.

Fixes: #4255
Fallback to the threadpool if it returns `EOPNOTSUPP`.

Fixes: nodejs/node#50876
huseyinacacak-janea and others added 30 commits February 10, 2025 12:32
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.
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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.