Commit Graph

1644 Commits

Author SHA1 Message Date
Juan José
d64c26d36a
Merge 75279c308e into 901e28384b 2026-03-27 19:10:20 +01:00
Saúl Ibarra Corretgé
901e28384b
test: use correct type for uv_fileno arguments (#4673)
Fixes a -Wincompatible-pointer-types error on Windows, since uv_os_fd_t
is not int but HANDLE.
2026-03-25 20:29:59 -04:00
Jameson Nash
fa0ac9ec0c
io: make libuv 64-bit safe (#5076)
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
2026-03-24 10:32:27 -04:00
BarryLhm
e3a27e0728
android: fix termux build (#5093)
Fixes: https://github.com/libuv/libuv/issues/5092
2026-03-24 09:59:50 +01:00
Ben Noordhuis
8877568581
unix: enforce recvmmsg buffer size requirements (#5095)
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
2026-03-23 21:25:33 +01:00
Ben Noordhuis
14f6c4cc1f
test: fix -Wunused-function warning (#5090)
The function is only used on BSDs. Introduced in commit 919b92d9 ("unix:
support long path names in pipe.c") from a few days ago.
2026-03-21 13:18:43 +01:00
Edy Silva
919b92d944
unix: support long path names in pipe.c (#5047)
Continues: #4676
Fixes: #2826
2026-03-16 23:14:47 -04:00
Juan José
f4363aeb44
test: remove unused headers and use newer ASSERT macros (#4760) 2026-03-16 21:51:03 -04:00
Jameson Nash
651f2fc161
test,win: fix race in test runner (#5066)
Port 143da93e to Windows: replace the 250 ms settle delay with a pipe-
based synchronization mechanism. The parent creates a pipe, passes the
write-end handle to the helper via UV_TEST_RUNNER_FD, then blocks on
ReadFile() until the helper calls notify_parent_process() and closes its
copy of the handle.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 13:04:26 -04:00
Oren
88d6d362f6
udp: validate nbufs in send functions 2026-03-14 12:05:35 +01:00
locus-x64
ec0ab5d77d
win: fix off-by-one in utf-16 to wtf-8 conversion (#5050)
Reserve one byte for the NUL terminator when passing the buffer size
to uv_utf16_to_wtf8() in the TTY line-read path. Without this, when
all input characters encode to exactly 3 UTF-8 bytes (e.g. CJK) and
the buffer size is divisible by 3, the NUL terminator is written one
byte past the allocated buffer.

The other two call sites in src/win/util.c already subtract 1 before
calling uv_utf16_to_wtf8(). This aligns tty.c with that convention.

Fixes commit f3889085 ("win,tty: convert line-read UTF-16 to WTF-8")
from October 2023.

Refs: https://github.com/libuv/libuv/security/advisories/GHSA-4prr-4742-3ccf
2026-03-13 11:59:12 +01:00
Juan José
b030b02a3e
linux: fix crash if poll callback closes handle before POLLERR (#5039)
Previously, `uv__udp_io` would proceed to call `uv__udp_recvmsg` for
the `POLLERR` event even if the handle was just closed by the `POLLIN`
callback.

This commit adds a guard to verify the handle is still active before
processing the error queue. It also adds a regression test that
mimics this recursive closure behavior.

Fixes: https://github.com/libuv/libuv/issues/5030

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2026-03-06 15:00:09 -05:00
Yasser Nascimento
568470a2ef test: remove conditionals from uv_thread_self usage
The Windows limitation was fixed in: https://github.com/libuv/libuv/pull/3357.
2026-03-06 09:44:50 +01:00
Saúl Ibarra Corretgé
edfc95dbd7 unix,win: support NULL loop for sync uv_getaddrinfo
Brings symmetry with the uv_fs_xxx APIs.
2026-02-19 13:18:14 +01:00
mischief
71801576eb unix: make OpenBSD uv_exepath work
some users of libuv rely on uv_exepath to be an actual path to a
program. unfortunately, the OpenBSD KERN_PROC_ARGV sysctl just returns
what is in argv[0], so if the program was executed by being looked up in
$PATH, uv_exepath would only return the basename and not an actual path.

to fix, this use the same approach as IBM i, OS/390 and AIX by searching
with uv__search_path. this is also the same approach the Zig language
has taken for the similar selfExePath function for OpenBSD.

the tests expect that uv_exepath still works after uv_set_process_title,
which on BSD is a call to setproctitle. the place setproctitle stores to
is the same place that KERN_PROC_ARGV reads from, so we need to stash
the original argv[0] in uv_setup_args to recover it later in uv_exepath.
2026-02-05 11:45:49 +01:00
Ben Noordhuis
885613f1fe
aix,ibmi: fix test suite build breakage (#5020)
Apparently there is no openpty() on those platforms. Introduced in
commit 2e2114ed from last month.

Fixes: https://github.com/libuv/libuv/issues/5018
2026-02-04 22:45:38 +01:00
tobil4sk
73bfbb995f
idna: fix assert in wtf8_to_utf16 conversion (#5021)
0x10FFFF is the valid max unicode character, so the check should be
inclusive.

This assert gets triggered because uv__wtf8_decode1 (used by
uv_wtf8_length_as_utf16) has the correct code_point <= 0x10FFFF check,
so the sequence is treated as valid and it will be passed into
uv_wtf8_to_utf16, where the incorrect assert gets triggered:

src/idna.c:397: uv_wtf8_to_utf16: Assertion `code_point < 0x10FFFF' failed.
2026-02-04 21:55:43 +01:00
Ben Noordhuis
fc90bb9843
unix: remove sunpro references (#5017)
Sun Studio / Oracle Developer Studio hasn't had a release in almost
nine years. If Oracle doesn't feel like supporting it, then neither
do I.
2026-02-02 23:15:38 +01:00
Santiago Gimeno
c68ca444e7
win: refactor to support large statfs blocks (#5016)
Accomplish this by replacing `GetDiskFreeSpaceW()` with
`NtQueryVolumeInformationFile()` which allows us to represent blocks
larger than 2^32 - 1 via
`FILE_FS_FULL_SIZE_INFORMATION.TotalAllocationUnits`.

Expanded `fs_statfs` test to check that `uv_fs_statfs()` also works with
files, meaning https://github.com/libuv/libuv/issues/2683 remains fixed
without the need of https://github.com/libuv/libuv/pull/2695.
2026-02-02 10:04:36 +01:00
Ben Noordhuis
91dc2389cc
unix,win: check nbufs argument is reasonable (#5014)
Catch sign conversion bugs by introducing a bounds check that doubles
as a sanity check.

Fixes: https://github.com/libuv/libuv/issues/5012
2026-02-01 13:03:07 +01:00
Ben Noordhuis
4839e28d50
test: disable tcp_reuseport test under qemu (#5005)
The test is multi-threaded and expects both threads to receive at least
some of the incoming connections but there isn't always true parallelism
under QEMU's user-mode emulator.

Single-core systems are also susceptible to that so also add a check
that we have at least two cores to run on.

As mentioned in the change for the udp_reuseport test from a few days
ago, the test is not perfect (there being > 1 core doesn't guarantee
we actually get to run on them) but it's better than nothing.

Fixes: https://github.com/libuv/libuv/issues/5003
2026-01-23 11:07:15 +01:00
Ben Noordhuis
0405e1224f
test: disable udp_reuseport test under qemu (#5002)
The test is multi-threaded and expects both threads to receive at least
some of the incoming datagrams but there isn't always true parallelism
under QEMU's user-mode emulator.

Single-core systems are also susceptible to that so also add a check
that we have at least two cores to run on.

It's not perfect because a sufficiently dedicated test torturer could
probably concoct a containerized setup where the core count > 1 but the
available CPU slice is so small that the test effectively still runs
sequentially, but it's better than nothing.

Fixes: https://github.com/libuv/libuv/issues/4777
2026-01-21 22:34:30 +01:00
Ben Noordhuis
2e2114ed89
unix: fix partial read handling after POLLHUP (#4997)
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: https://github.com/libuv/libuv/issues/4992
2026-01-18 12:21:53 +01:00
Cody Tapscott
588ea9b913
win: readlink support for IO_REPARSE_TAG_LX_SYMLINK (#4994)
This adds support for "Linux"-style Windows symbolic links, reparse tag
0xA000001D (IO_REPARSE_TAG_LX_SYMLINK).
2026-01-16 10:38:18 +01:00
Ben Noordhuis
3908e54252
test: make pty test work under asan (#4996)
AddressSanitizer was right to complain about the test because it was
passing an uninitialized `struct winsize` to openpty().
2026-01-15 21:39:23 +01:00
Ben Noordhuis
d67f9d2fba
test: fix -Wstringop-overread warning (#4993)
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]
2026-01-13 14:35:19 +01:00
Ben Noordhuis
f420c2bd57
test: fix -Wuninitialized-const-pointer warning (#4990)
Zero the struct. The compiler is not aware it's not actually used.
2026-01-07 23:24:28 +01:00
Ben Noordhuis
91ae02a63d
unix,win: add f_frsize field to uv_statfs_t (#4984)
Fixes: https://github.com/libuv/libuv/issues/4983
2026-01-01 22:33:44 +01:00
Santiago Gimeno
9c876b2f3b
test: run more fs tests using io_uring too (#4970)
Fix `threadpool_cancel_fs_iouring` so it takes `UV_FS_FTRUNCATE` into
account.
2025-12-20 22:30:42 +01:00
Ben Noordhuis
ac591507f3
ci: add macos-15-intel to matrix (#4968)
And fix a stupid typo that made GHA skip running the tests 🤦
2025-12-10 20:43:08 +01:00
Santiago Gimeno
fd89e63f2f linux: fix uv_fs_ftruncate io_uring implementation (#4963 2/2)
The `offset` field should be assigned to ithe `io_uring_sqe.off` field.
2025-12-08 10:31:45 +01:00
Santiago Gimeno
e522b27da3 test: add macros to run fs tests with io_uring (#4963 1/2)
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.
2025-12-08 10:31:45 +01:00
Juan José
80a5e3ba01
linux: add MSG_ERRQUEUE ipv4/ipv6 udp support (#4902)
Fixes: https://github.com/libuv/libuv/issues/4447
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Co-authored-by: theanarkh <theratliter@gmail.com>
2025-10-06 16:45:58 +02:00
Juan José
50f281c044
test: make thread_priority robust against system default nice levels (#4901)
The test previously assumed a default nice value of 0, but this can vary
depending on PAM configuration, /etc/security/limits.conf, or other environment
settings.

Fixes: https://github.com/libuv/libuv/issues/4898

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-10-03 11:32:58 -04:00
Ben Noordhuis
12fbd34475
win: shrink fd hash table from 2592k to 162k (#4869)
The static initial table reserved space for MxN elements but only used
every Nth element. Removing the excess elements shrinks the table 16x.

I added search/insertion/deletion time logging while here to ensure no
performance regressions.

Fixes: https://github.com/libuv/libuv/issues/4823
2025-08-24 20:22:54 +02:00
Ben Noordhuis
a9c8da7726
test,win: fix -Wattributes warnings (#4868)
Fixes: https://github.com/libuv/libuv/issues/4865
2025-08-24 20:22:23 +02:00
Ben Noordhuis
9a8d9c66f3
test,win: fix -Wcast-function-type warnings (#4867) 2025-08-24 20:22:04 +02:00
Ben Noordhuis
385896c388
test,win: fix -Wunused-function warnings (#4866) 2025-08-24 20:21:46 +02:00
Emily
8aad181416
test: use relative paths for pipes and unix sockets (#4850)
This fixes the test suite in environments where `/tmp` is not writable
or does not allow the use of Unix sockets, and matches the use of
relative paths elsewhere in the tests.
2025-08-16 22:08:55 +02:00
Jameson Nash
a21e7cfaf8
test: simplify ASSERT_OK macro for static analysis (#4830)
I was testing a static analyzer on libuv's code, and it could not
understand the use of a constant variable in the condition as an assert
branch. This simplifies the code for easier static analysis. I also
removed the explicit casts, relying instead on C's casting rules to
catch some misuse.
2025-07-16 12:39:56 -04:00
Ben Noordhuis
aac866f399
test: skip slow process title test on asan+macos (#4825)
uv_set_process_title loads and unloads a bunch of dynamic libraries,
and that's quite slow and prone to time out when running concurrently
under AddressSanitizer.
2025-07-06 16:19:51 +02:00
Ben Noordhuis
aad85404cc
test: pass correct string type to GetModuleHandleW (#4820)
Introduced in commit 2545ffe74 from last month.
2025-07-06 15:39:37 +02:00
Deep C
04fc1580d4
qnx: add qnx 8 support (#4801)
Fixes: https://github.com/libuv/libuv/issues/4710
2025-06-30 08:26:11 +02:00
chemodax
2545ffe74c
win: replace GetModuleHandleA with GetModuleHandleW (#4812) 2025-06-29 20:32:14 +02:00
Andy Pan
3a9a6e3e6b
tcp: support customizing TCP_KEEPINTVL and TCP_KEEPCNT
Implement `uv_tcp_keepalive_ex` function that extends
`uv_tcp_keepalive` to support `TCP_KEEPINTVL` and `TCP_KEEPCN`
socket options in addition to TCP_KEEPIDLE.
2025-05-21 08:43:53 +02:00
Ryan Liptak
2b76a4fafa
unix: fix uv_thread_{get,set}priority error codes (#4782)
pthread_getschedparam and pthread_setschedparam do not use errno but
instead return the error code directly.

https://pubs.opengroup.org/onlinepubs/9799919799/functions/pthread_getschedparam.html

Also include a fix to return UV_ESRCH instead of UV_EBADF on Windows,
like Unix systems do.
2025-05-15 09:16:25 +02:00
Juan José
8d4218dcd7
test: remove unused include of <limits.h> in runner.h (#4780)
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-05-10 10:04:59 -04:00
Juan José
e4ed92aad7
test: skip udp_multicast_join if not system-wide available (#4779)
Fixes: https://github.com/libuv/libuv/issues/4778

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-05-08 12:39:26 -04:00
Juan José
47a5c85c4e
test: skip multievent tests on macOS with TSAN enabled (#4763)
Fixes: https://github.com/libuv/libuv/issues/4659
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-04-22 22:09:25 +02:00
Juan José
086da2c458
test: merge uv_tcp_connect callbacks (#4761)
Distinguish a callback for v4 and v6 connections is not relevant for
this test.

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-04-20 15:17:49 -04:00