1
0
mirror of https://github.com/libuv/libuv synced 2025-03-28 21:13:16 +00:00

1592 Commits

Author SHA1 Message Date
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
Juan José Arboleda
a94f2ad2b7 build: enable fdsan in Android
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: https://github.com/libuv/libuv/issues/4369
2024-12-16 09:01:15 +01:00
Juan José
3d78d121f4
test: fix flaky flaky udp_mmsg test (#4652)
Replace comparison of `alloc_cb_called` with the total bytes
read (`bytes_read`) to validate the test's correctness.

Fixes: https://github.com/libuv/libuv/issues/4650
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-12-15 20:24:20 +01:00
Ben Noordhuis
e8969bff6c unix,win: add uv_udp_try_send2
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.
2024-12-13 21:52:59 +01:00
Juan José
acebb97490
test: address FreeBSD kernel bug causing NULL path in fsevents (#4649)
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: https://github.com/libuv/libuv/issues/4606

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-12-13 15:30:17 -05:00
Jameson Nash
72d9abccd7
win,fs: get (most) fstat when no permission (#4566)
Replaces: https://github.com/libuv/libuv/pull/4504
Fixes: https://github.com/libuv/libuv/issues/1980
Fixes: https://github.com/libuv/libuv/issues/3267

Co-authored-by: Hüseyin Açacak <huseyin@janeasystems.com>
2024-12-12 15:05:53 -05:00
Saúl Ibarra Corretgé
16e6e84dcc
win: drop support for the legacy MinGW (#4645)
The OG MinGW has been dead for years, MinGW-w64 has taken its place.
2024-12-12 15:59:30 +01:00
Saúl Ibarra Corretgé
7752218db2 fixup! 2024-12-12 15:55:16 +01:00
Ben Noordhuis
2494c088f0
unix,win: handle nbufs=0 in uv_udp_try_send (#4641) 2024-12-09 21:14:01 +01:00
Santiago Gimeno
61c966cf0b
src: add uv_thread_set/getname() methods (#4599)
`uv_thread_setname()` sets the name of the current thread. Different
platforms define different limits on the max number of characters
a thread name can be: Linux, IBMi (16), macOS (64), Windows (32767),
and NetBSD (32), etc. `uv_thread_setname()` will truncate it in case
`name` is larger than the limit of the platform.

`uv_thread_getname()` gets the name of the thread specified by `tid`.
The thread name is copied into the buffer pointed to by `name`. The
`size` parameter specifies the size of the buffer pointed to by `name`.
The buffer should be large enough to hold the name of the thread plus
the trailing NUL, or it will be truncated to fit.
2024-11-27 12:52:18 +01:00
Juan José
556a0f1f0f
unix,win: add support for detached threads (#4621)
This commit introduces the `uv_thread_detach` for thread detaching,
allowing threads to be detached state on both UNIX and Windows platforms.

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-11-26 08:44:38 -05:00
Saúl Ibarra Corretgé
c6d43bea09
unix,win: harmonize buffer checking
For any API that takes a buffer and size pointer, check both pointers
and the pointed-to size and return UV_EINVAL in case of error.

Example:

```
int uv_foo(char* buffer, size_t* size) {
  if (buffer == NULL || size == NULL || *size == 0)
    return UV_EINVAL;
  ...
}
```

In order to "peek" the necessary size for dynamic allocation, the
following pattern can be used:

```
char *buf;
char scratch[1];
size_t len = sizeof(scratch);
int r;
r = uv_foo(scratch, &len);
assert(r == UV_ENOBUFS);
buf = malloc(len);
r = uv_foo(buf, &len);
...
```
2024-11-25 15:10:47 +01:00
Saúl Ibarra Corretgé
31ea3411cc unix,pipe: fix handling null buffer in uv_pipe_get{sock,peer}name
Fixes: https://github.com/libuv/libuv/issues/4610
2024-11-22 08:57:45 +01:00
dependabot[bot]
d05744e3ed
build(deps): bump actions/checkout from 3 to 4 (#4490)
Requires updating the android builder, since the arm emulator is
deprecated and unavailable now. Switch to using a Github Action plugin
instead of a container, so that hopefully future updates will be
delivered via that channel instead.

Changed the idna test since printf returns EILSEQ for some byte
sequences in the format on Android in glibc. We don't fully understand
the cause, but we can avoid that by not asking it to reencode the bytes
in the current locale settings.
2024-11-21 08:38:56 -05:00
Ben Noordhuis
c6b67af390
unix,win: fix off-by-one in uv_wtf8_to_utf16() (#4609)
uv_wtf8_length_as_utf16() checks if codepoints are > 0xFFFF (to see if
it should be encoded as a surrogate pair), therefore uv_wtf8_to_utf16()
should too. Instead it checked > 0x1000. Harmonize the checks.

Fixes: https://github.com/nodejs/node/issues/55914
2024-11-19 19:09:03 +01:00
Saúl Ibarra Corretgé
d4ab6fbba4 darwin,test: squelch EBUSY error on multicast join
The firewall was suspected to be the culprit, but the test
intermittently fails in the CI, not locally.
2024-10-22 10:26:32 +02:00
Saúl Ibarra Corretgé
a3abfbcb08 test: skip multicast join test on ENOEXEC
It happens due to the default firewall configuration on macOS >= 13.

Note: GH action runners have their firewall disabled, and yet, the test
fails all the same. Oh well...

Closes: https://github.com/libuv/libuv/issues/4263
2024-10-22 10:26:32 +02:00
Jameson Nash
7e6590f31d
win: remap ERROR_NOACCESS and ERROR_BUFFER_OVERFLOW (#4567)
It seemed incorrect to map a segfault to EACCES, since posix would typically
map this to EFAULT. The ERROR_BUFFER_OVERFLOW is literally "the filename is too
long", and is not typically an invalid parameter in posix.

Test originally added in #1060 to test the API, not the value.
2024-10-17 15:37:00 -04:00
Hüseyin Açacak
fbe2d85bd5 win,fs: remove trailing slash in junctions
Fixes: https://github.com/libuv/libuv/issues/3329
2024-10-15 09:48:27 +02:00
Hüseyin Açacak
1cbffcbd5d win,fs: fix bug in fs__readdir 2024-10-04 13:33:22 +02:00
Santiago Gimeno
88b874e63c
win,fs: uv_fs_rmdir() to return ENOENT on file (#4563)
After commit 18266a6969, it changed to return `ENOTDIR`, which makes it
consistent with other platforms but it also can be considered a breaking
change.
2024-10-03 21:29:10 +02:00
Edigleysson Silva (Edy)
5bb19f35ea
test: run android tests on ci (#4517) 2024-09-17 21:30:24 +02:00
Ben Noordhuis
9dddebab0d
test: delete test with invalid assumption (#4530)
Delete the fs_event_error_reporting test. It fails in different ways,
most frequently on the TSan sanitizer buildbot, due to running out of
file descriptors when that is not expected, or vice versa, *not*
running out of file descriptors when that *is* expected.

The test creates a large number of event loops and expects to,
eventually, hit EMFILE but it sometimes hits it too early, and
sometimes not at all.

I don't think TSan is really responsible here, it just makes the
invalid assumption in the test itself more visible.

Fixes: https://github.com/libuv/libuv/issues/4368
2024-09-12 22:19:10 +02:00
Andy Pan
44e61dab7e
kqueue: disallow ill-suited file descriptor kinds (#4513)
Follows up on https://github.com/libuv/libuv/pull/659.

Signed-off-by: Andy Pan <i@andypan.me>
2024-09-09 20:22:15 +02:00
Ben Noordhuis
1eac3310ad
linux: support abstract unix socket autobinding (#4499)
Autobinding is a feature that lets the kernel pick a name for the
abstract socket, instead of userspace having to provide one.

Two bugs that this change exposed are also fixed:

1. strlen(sa.sun_path) can read past the end if the file path is exactly
   sizeof(sa.sun_path) long (use memchr instead), and

2. don't return UV_ENOBUFS for abstract sockets when the buffer is
   exactly large enough to hold the result; per commit e5f4b79809,
   abstract socket names are not zero-terminated
2024-08-10 21:04:09 +02:00
Richard Lau
c84a2dbe03 test: check for UV_CHANGE or UV_RENAME event
All other checks for `UV_RENAME` in `test-fs-event` also allow
`UV_CHANGE`.
2024-08-08 12:03:25 +01:00
Richard Lau
88ab6e78da test: rmdir can return EEXIST or ENOTEMPTY
POSIX allows `rmdir` to return `EEXIST` or `ENOTEMPTY` for a non-empty
directory, so the test needs to allow both.
2024-08-08 12:03:25 +01:00
Matheus Izvekov
9b3b61f606
build: ubsan fixes (#4254)
MSVC does not actually support ubsan. There is a long-standing ticket
requesting this:
https://developercommunity.visualstudio.com/t/add-support-for-ubsan/840750

There are no known compilers that currently accept the
`/fsanitize=undefined` spelling. clang-cl accepts `-fsanitize...`,
same as regular clang.

Also passes no-sanitizer-recover so that tests actually fail.

Fix various ubsan-detected errors, including:

* win: fix req-inl.h ubsan failure

Don't use CONTAINING_RECORD macro from WinSDK, as it doesn't use the
right trick which avoids member access on null pointer.

Fixes:
```
src/win/req-inl.h:86:10: runtime error: member access within null pointer of type 'uv_req_t' (aka 'struct uv_req_s')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior D:/a/libuv/libuv/src/win/req-inl.h:86:10
```

* test: fix ubsan failure on udp_ref3

Don't call functions through different function type.

Fixes:
```
src/win/udp.c:537:5: runtime error: call to function req_cb through pointer to incorrect function type 'void (*)(struct uv_udp_send_s *, int)'
test\test-ref.c:66: note: req_cb defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/udp.c:537:5 in
```

* win: fix process-stdio.c ubsan failure

When accessing HANDLEs within the stdio buffer, use memcpy / memset in order to respect alignment.

Fixes:
```
src/win/process-stdio.c:197:5: runtime error: store to misaligned address 0x0230ee72d107 for type 'HANDLE' (aka 'void *'), which requires 8 byte alignment
0x0230ee72d107: note: pointer points here
  00 00 cd cd cd  cd cd cd cd cd cd cd cd  cd cd cd cd cd cd cd cd  cd cd cd cd cd cd cd fd  fd fd fd
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/process-stdio.c:197:5 in
```

* win: fix getaddrinfo.c ubsan failure

Reworks buffer alignment handling to respect requirements.

Fixes:
```
src/win/getaddrinfo.c:157:23: runtime error: member access within misaligned address 0x0290e4c6a17c for type 'struct addrinfo', which requires 8 byte alignment
0x0290e4c6a17c: note: pointer points here
  00 00 00 00 cd cd cd cd  cd cd cd cd cd cd cd cd  cd cd cd cd cd cd cd cd  cd cd cd cd cd cd cd cd
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/getaddrinfo.c:157:23 in
```

* win: fix pipe.c ubsan failure

Changes "random" representation from pointer to number.

Fixes:
```
src/win/pipe.c:234:11: runtime error: applying non-zero offset to non-null pointer 0xffffffffffffffff produced null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/pipe.c:234:11 in
```

* unix: fix stream.c ubsan failure

Avoids performing pointer arithmetic on null pointer.

Fixes:
```
src/unix/stream.c:701:15: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/runner/work/libuv/libuv/src/unix/stream.c:701:15 in
```
2024-08-05 17:15:53 -04:00
Abdirahim Musse
f23037fe21
test: pipe_overlong_path handle ENAMETOOLONG 2024-07-30 08:07:52 +02:00
Santiago Gimeno
badecdca14
fsevents: detect watched directory removal (#4376)
Which was broken both in `windows` and `macos`.
2024-07-30 00:59:38 +02:00
Hüseyin Açacak
83306585ff
win: fix env var in uv_os_homedir and uv_os_tmpdir (#4464)
If the corresponding environment variables are empty, the
uv_us_homedir() and uv_os_tmpdir() return garbage values. The reason
for this situation is the Windows API which doesn't return an error
even if the path is empty.

This PR fixes this problem by checking the return value of the API
call. If it is not an error and the length of the value is less than 3,
uv_us_homedir() and uv_os_tmpdir() will return UV_ENOENT.

Fixes: https://github.com/libuv/libuv/issues/2328
2024-07-29 17:50:11 -04:00
Ian Butterworth
18266a6969
win,fs: use posix delete semantics, if supported (#4318)
Implements posix delete for files and dirs, with fallback to the old
method if not supported (e.g. Fat32 or Win8).

Fixes: #3839
2024-07-29 17:38:26 -04:00
Ben Noordhuis
0c36b16d1b
test,openbsd: remove superfluous ifdef guard (#4461)
The test is skipped in its entirety on OpenBSD so there is no point in
compiling out code on said platform later on, it's not run anyway.
2024-07-29 16:45:31 -04:00
Ben Noordhuis
593aa3b2f6
test: handle zero-length udp datagram (#4344)
Under rare but benign circumstances (on XNU), incoming datagrams appear
to be dropped by the operating system after libuv has been notified of
their arrival but before libuv has had a chance to receive them.

Fixes: https://github.com/libuv/libuv/issues/4219
2024-07-29 16:30:08 -04:00
Andy Pan
ba24986f8d
unix: support SO_REUSEPORT with load balancing for UDP (#4419)
Signed-off-by: Andy Pan <i@andypan.me>
2024-06-20 17:17:17 +02:00
Andy Pan
1ee1063402
test: fix the flaky test-tcp-reuseport
Start connecting to the peers after all threads
to poll for accepting connections.

Ref: #4407
2024-05-30 09:53:44 +02:00
Andy Pan
d2d92b74a8
unix: support SO_REUSEPORT with load balancing for TCP 2024-05-21 13:36:49 +02:00
Andy Pan
287987b37c test: remove the obsolete HAVE_KQUEUE macro
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-05-21 09:40:07 +02:00
Juan José
bf61390769
linux,darwin: make uv_fs_copyfile behaves like cp -r (#4396)
This commit changes the timestamps in the file, the ownership and the
group.

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

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-05-08 11:30:30 +02:00
Ben Noordhuis
17219b8f39
test: use newer ASSERT_MEM_EQ macro (#4346)
Should hopefully make it easier to debug CI flakiness because
currently the test sometimes fails without a clear indication why.

Refs: https://github.com/libuv/libuv/issues/4106
2024-03-31 17:27:04 +02:00
Saúl Ibarra Corretgé
6adeeacee7
unix,win: error on zero delay tcp keepalive
Closes: https://github.com/libuv/libuv/pull/4350
Closes: https://github.com/libuv/libuv/issues/3487
2024-03-22 22:11:23 +01:00