Commit Graph

1632 Commits

Author SHA1 Message Date
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
Ben Noordhuis
942e1418ea
unix: improve uv_loop_init OOM handling (#4757)
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: https://github.com/libuv/libuv/issues/4755
2025-04-18 16:23:51 +02:00
Itay Bookstein
c1a9f01f22
linux: allow nul bytes in abstract socket address (#4737)
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>
2025-03-27 08:48:56 +01:00
Colin Ihrig
2b96e47f12
test: support partial output lines in test runner (#4744)
This commit updates the test runner's print_lines() logic to
better handle partial lines.
2025-03-24 00:00:22 -04:00
Abdirahim Musse
92eacd19a1
test: skip thread_name_threadpool on AIX/IBMi (#4731)
uv_thread_getname is not available on aix and ibm i
Same issue as thread_name test
Refs: https://github.com/libuv/libuv/pull/4599#issuecomment-2498376606
2025-03-03 13:12:48 -05:00
Colin Ihrig
f61f9c29d8
test: handle UV_ENOTSUP in platform_output (#4714)
Fixes: https://github.com/libuv/libuv/issues/4713
2025-02-25 13:22:10 -05:00
Anna Henningsen
843b64faf5
win: add ENABLE_VIRTUAL_TERMINAL_INPUT raw tty mode (#4688)
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 https://github.com/nodejs/node/commit/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. 4e7942135f/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: 87af913b66
Refs: https://github.com/microsoft/terminal/issues/4954
2025-02-21 23:34:53 +01:00
Ben Noordhuis
85b526f56a
unix,win: accept NAN/INFINITY as file timestamps (#4702)
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: https://github.com/libuv/libuv/issues/4665
2025-02-21 23:08:15 +01:00
Hüseyin Açacak
82cdfb75ff win: fix the inconsistency in volume serial number 2025-02-17 08:35:37 +01:00
Juan José
be8eec8c5a
misc: implement uv_getrusage_thread (#4666)
Refs: https://github.com/libuv/libuv/issues/3119

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Co-authored-by: James M Snell <jasnell@gmail.com>
2025-01-14 14:50:26 +01:00
Rafael Gonzaga
e59e2a9e49
src: set a default thread name for workers (#4664) 2025-01-08 13:58:28 +01:00
Juan José
beebf02cf6
test: fix udp-multicast-join for FreeBSD (#4655)
Fixes: https://github.com/libuv/libuv/issues/4651

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-12-16 09:05:09 +01:00