Commit Graph

5079 Commits

Author SHA1 Message Date
Ben Noordhuis
e0a5f58d2c
test: fix ipc_send_recv_pipe flakiness (#3478)
The read callback failed to handle the `nread == 0` case, which is rare
to non-existent on the systems we test on but apparently happens often
enough on Solaris on SPARC to draw attention.

Fixes #3469.
2022-02-20 12:17:13 +01:00
Santiago Gimeno
2bc22c40eb test: fix flaky udp_mmsg test
Take into account that the data may not be already available in the
socket causing the `recvmsg()` / `recvmmsg()` calls to return `EAGAIN`
or `EWOULDBLOCK`.

Fixes: https://github.com/libuv/libuv/issues/3479
2022-02-17 17:34:36 +01:00
Jameson Nash
d54c92e3e6
win: fix style nits [NFC] (#3474)
Internal functions usually have a uv__ prefix.
2022-02-15 10:13:24 -05:00
Ben Noordhuis
d41a9a07e4
doc: clarify android api level (#3480)
Google goes to great lengths to obscure the relationship between the two
so explicitly call out the API version matching Android 7.0.
2022-02-15 10:10:22 -05:00
Jameson Nash
cc7dbaa3a1
fix oopsie from #3466 (#3475)
I created `uv__backend_timeout` to be used internally for this reason,
then forgot to use it, resulting in flaky tests and excessive trips
around the uv_run loop.

Fix #3472
2022-02-14 13:37:05 -05:00
Jameson Nash
3b2c25d223
win,fs: avoid closing an invalid handle (#3473)
While usually functional, calling CloseHandle(INVALID_HANDLE_VALUE) can
result in debug builds (and/or wine) being unhappy and aborting there.
2022-02-14 12:29:47 -05:00
twosee
0209466496
win,loop: add missing uv_update_time (#3175)
Time of loop should be updated after the IOCP wait.
2022-02-14 11:40:42 -05:00
Paul Evans
722d003076
document the values of enum uv_stdio_flags (#3039)
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
2022-02-14 11:37:19 -05:00
Momtchil Momtchev
df78de04e4
win,fs: consider broken pipe error a normal EOF (#3053)
This would later get translated in src/win/error.c this way, which
previously could lead to rather confusing and inaccurate error messages.
2022-02-13 01:40:10 -05:00
Ryan Liptak
912bb8c577
test: fix benchmark-ping-udp (#2817)
- Fixes the declaration of the benchmark in benchmark-list.h (it was not
  previously runnable at all)
- Fixes the benchmark itself hanging infinitely because the data was
  being dropped via ICMP Destination Unreachable errors (meaning nread
  was always zero in pinger_read_cb)
    + The data getting lost was fixed by binding the udp socket
- Properly checks for UV_UDP_MMSG_CHUNK, just as an example of what
  should generally be done (buf_free is actually a no-op as the buf is
  allocated on the stack)
2022-02-13 01:04:41 -05:00
UMU
8ec1732af0
build: fix error C4146 on MSVC (#3271)
> error C4146: unary minus operator applied to unsigned type, result still unsigned
2022-02-13 00:57:43 -05:00
Momtchil Momtchev
636cb8633b
bench: add uv_queue_work ping-pong measurement (#3425) 2022-02-13 00:40:35 -05:00
Darshan Sen
04a35efe69
win,errors: remap ERROR_ACCESS_DENIED to UV_EACCES (#3193)
If we try to use uv_fs_rmdir on a read-only directory on Windows, it
internally calls _wrmdir, which sets _doserrno to ERROR_ACCESS_DENIED
and errno to EACCES. However, ERROR_ACCESS_DENIED is mapped to
UV_EPERM, so I believe it should be remapped to UV_EACCES.
2022-02-13 00:31:59 -05:00
jonilaitinen
cf7f70c25d
win: restrict system DLL load paths (#3395)
Currently `LoadLibraryA` call first attempts to load the given DLL from
the application working directory before loading it from the system DLL
path. This may pose a security risk if an attacker is able to place a
malicious DLL into the application working directory as that DLL will
be loaded instead of the system DLL. This is especially dangerous if
the application is running with elevated privileges.

This changes the DLL loading to use `LoadLibraryExA` method with
`LOAD_LIBRARY_SEARCH_SYSTEM32` flag which restricts the DLL load
path to system DLL path, ignoring any DLLs in the application working
directory.
2022-02-13 00:26:55 -05:00
Jameson Nash
d0e500c876
win: use GetTickCount64 for uptime again (#3470)
Reverts 442aa1f469, since this is an
improved API in Windows Vista that is now usable as a replacement. It
simplifies the code substantially, while returning nearly the same
result (on my system, the performance counters were 6 seconds behind).

The old code also did not work on Wine-5.0 (where I observed that
`data_size == data_block->HeaderLength`, and so no data was present).
2022-02-13 00:24:34 -05:00
Jameson Nash
939a05633f
loop: add pending work to loop-alive check (#3466)
Pending work may be either (on any platform) pending_queue callbacks or
(on unix) watcher_queue handles to add to the io poll object.
Previously, we might have gotten somewhat stuck if the user caused an
event to be added to one of these in the idle or prepare callbacks, or
was embedding libuv.

Refs: https://github.com/libuv/libuv/pull/3234
Refs: https://github.com/libuv/libuv/issues/3101
Refs: https://github.com/libuv/libuv/pull/3308
2022-02-13 00:12:11 -05:00
WenTao Ou
7a68f5ab4b
build: export uv_a for cmake (#3373) 2022-02-08 11:43:19 -05:00
Luca Adrian L
50c1d00839
win: return fractional seconds in uv_uptime() (#3455)
Some systems return fractional seconds, some return full seconds.
On Windows uptime was artificially rounded down.

Fixes #3447.
2022-02-08 14:23:39 +01:00
Ben Noordhuis
de24da8c11
darwin: bump minimum supported version to 10.15 (#3406)
We can't realistically claim to support 10.7 or any version that Apple
no longer supports so let's bump the baseline to something more
realistic.

Refs: https://github.com/libuv/libuv/pull/482
Refs: https://github.com/libuv/libuv/pull/3405
2022-02-08 14:18:29 +01:00
Ben Noordhuis
038086dc08
test: remove flaky test ipc_closed_handle (#3464)
The test is very flaky, both on the CI and on people's local machines.

I spent some time trying to fix it but its design is fairly questionable
and it fails to test what it should more often than not because on fast
machines no queueing of data takes place.

Fixes #2307.
2022-02-08 14:18:10 +01:00
Jameson Nash
953f901dd2
process,bsd: handle kevent NOTE_EXIT failure (#3451)
The kernel may return ESRCH if the child has already exited here.
This is rather annoying, and means we must indirectly handle
notification to our event loop of the process exit.

Refs: https://github.com/libuv/libuv/pull/3441
Refs: https://github.com/libuv/libuv/pull/3257
2022-02-01 15:27:12 -05:00
woclass
870828c8af
doc/guide: update content and sample code (#3408)
- Add `Makefile` for example codes. (cherry-pick from old uvbook repo)
- Add a new example "Default loop" to "Basics of libuv"/"Default loop"
- Document review and update: `Introduction`, `Basics of libuv`, `Filesystem`
    + Update the referenced libuv code snippet
    + Link update: http->https
    **Content Updates**:
    - `filesystem.rst`#L291-L297: Add note for `uv_fs_event_start`
    - `filesystem.rst`#L334: Add description of the callback function parameter `status`

The following examples have been tested manually in WSL2 (Ubuntu 20.04) with libuv 1.42.0:
- helloworld
- default-loop
- idle-basic
- uvcat
- uvtee
- onchange (test on macOS)

Co-authored-by: Nikhil Marathe <nsm.nikhil@gmail.com>
2022-01-31 16:52:42 -05:00
Jameson Nash
930af43437
build: rename CFLAGS to AM_CFLAGS (#3431)
The CFLAGS variable is reserved and should never be set:
https://www.gnu.org/software/automake/manual/html_node/User-Variables.html
2022-01-31 16:50:32 -05:00
ssrlive
cdced3a3ad
thread,win: fix C90 style nit (#3393) 2022-01-31 16:49:01 -05:00
Jameson Nash
125da33f82
build: fix cmake install locations (#3415)
Adds static libraries and DLL import libraries, as well as making sure
the DLLs go to the correct folder.

Closes #3414
2022-01-31 16:25:20 -05:00
Momtchil Momtchev
e89abc80ea
test: fix flaky uv_fs_lutime test (#3424)
Disable `atime` testing for symlink as this test
is dependant on a race condition on some OSes
(Linux is one) as `lstat` updates the `atime`.
As both `mtime` and `atime` are set by the same
syscall, barring an eventual kernel bug, this
test does not omit any error case.
2022-01-31 16:25:05 -05:00
Jeremy Rose
d9e90857f0
process: monitor for exit with kqueue on BSDs (#3441)
This adds a workaround for an xnu kernel bug that sometimes results in
SIGCHLD not being delivered. The workaround is to use kevent to listen
for EVFILT_PROC/NOTE_EXIT events instead of relying on SIGCHLD on *BSD.
 
Apple rdar: FB9529664
Refs: https://github.com/libuv/libuv/pull/3257
2022-01-31 14:49:22 -05:00
Jiawen Geng
bb0b4bb783
doc: add gengjiawen as maintainer (#3430) 2022-01-20 22:08:14 +08:00
Ben Noordhuis
e43eb667b5
bsd: ensure mutex is initialized (#3428)
The process title mutex was destroyed on library unload without ensuring
it was initialized - and it may not be because it's initialized lazily.

On most platforms it worked by accident because an "all zeroes" mutex is
synonymous with an initialized and unlocked mutex, but not on NetBSD.

Refs: https://github.com/libuv/libuv/pull/3286#issuecomment-1014058782
2022-01-17 12:55:41 +01:00
Ben Noordhuis
b5fa965bcb
unix: don't allow too small thread stack size (#3423)
uv_thread_create_ex() lets you set a stack size that is smaller than is
safe. It enforces a lower bound of PTHREAD_STACK_MIN (when that constant
is defined) but with musl libc that's still too small to receive signals
on.

Put the lower bound at 8192 or PTHREAD_STACK_MIN, whichever is greater.
The same restriction was already in place for the _default_ stack size.
2022-01-17 09:36:26 +01:00
Ondřej Surý
d5ed7f1256 test: test with maximum recvmmsg buffer (#3419)
The maximum numbers receivable by the recvmmsg call is defined in
src/unix/udp.c as UV__MMSG_MAXWIDTH with the current value being 20.

Align the size of the receive buffer in the mmsg test to receive the
maximum number of UDP packets in the test.
2022-01-15 06:24:37 +01:00
Ondřej Surý
e9cb18484e unix: ensure struct msghdr is zeroed in recvmmsg (#3419)
With MUSL libc, the struct msghdr is padded to align with the types used
in the Linux kernel headers (int vs size_t).  When the padding was not
zeroed, the syscall would return EMSGSIZE because the random bytes in
the padding would be read by kernel as part of the size_t type.

Fixes: https://github.com/libuv/libuv/issues/3416
2022-01-15 06:24:37 +01:00
Jessica Clarke
2fbfa0358b
unix: fix STATIC_ASSERT to check what it means to check (#3417)
Currently it's checking pointers to the uv_buf_t fields match the size
of the iovec fields. This is true on traditional architectures where
pointers are just machine word-sized integers, but not on CHERI, and
thus Arm's Morello prototype, where pointers contain additional metadata
(including bounds and permissions). Drop the & to fix this.
2022-01-13 06:20:14 +01:00
Ben Noordhuis
c8cbdbd2c4
android: use libc getifaddrs() (#3412)
Fixes: https://github.com/libuv/libuv/issues/3411
2022-01-13 05:55:25 +01:00
Ben Noordhuis
3a7b95593a
darwin: translate EPROTOTYPE to ECONNRESET (#3413)
macOS versions 10.10 and 10.15 - and presumbaly 10.11 to 10.14, too -
have a bug where a race condition causes the kernel to return EPROTOTYPE
because the socket isn't fully constructed.

It's probably the result of the peer closing the connection and that is
why libuv translates it to ECONNRESET.

Previously, libuv retried until the EPROTOTYPE error went away but some
VPN software causes the same behavior except the error is permanent, not
transient, turning the retry mechanism into an infinite loop.

Refs: https://github.com/libuv/libuv/pull/482
Refs: https://github.com/libuv/libuv/pull/3405
2022-01-12 16:11:43 +01:00
David Machaj
a3e02e5e4a
win: replace CRITICAL_SECTION+Semaphore with SRWLock (#3383)
Fixes: https://github.com/libuv/libuv/issues/3382
2022-01-12 16:07:17 +01:00
Colin Ihrig
2e42847f4e
doc: fix v1.43.0 changelog entries
PR-URL: https://github.com/libuv/libuv/pull/3407
2022-01-09 19:51:43 -05:00
Ben Noordhuis
abb109f30f
darwin: remove EPROTOTYPE error workaround (#3405)
It's been reported in the past that OS X 10.10, because of a race
condition in the XNU kernel, sometimes returns a transient EPROTOTYPE
error when trying to write to a socket. Libuv handles that by retrying
the operation until it succeeds or fails with a different error.

Recently it's been reported that current versions of the operating
system formerly known as OS X fail permanently with EPROTOTYPE under
certain conditions, resulting in an infinite loop.

Because Apple isn't exactly forthcoming with bug fixes or even details,
I'm opting to simply remove the workaround and have the error bubble up.

Refs: https://github.com/libuv/libuv/pull/482
2022-01-09 12:20:15 +01:00
cjihrig
bb6248bca4
Now working on version 1.43.1
Fixes: https://github.com/libuv/libuv/issues/3397
2022-01-04 09:27:20 -05:00
cjihrig
2c31ecb8fa
Add SHA to ChangeLog 2022-01-04 09:18:00 -05:00
cjihrig
988f2bfc4d
2022.01.05, Version 1.43.0 (Stable)
Changes since version 1.42.0:

* run test named ip6_sin6_len (Jameson Nash)

* docs: fix wrong information about scheduling (Mohamed Edrah)

* unix: protect fork in uv_spawn from signals (Jameson Nash)

* drop only successfully sent packets post sendmmsg (Supragya Raj)

* test: fix typo in test-tty-escape-sequence-processing.c (Ikko
  Ashimine)

* cmake: use standard installation layout always (Sylvain Corlay)

* win,spawn: allow UNC path with forward slash (earnal)

* win,fsevent: fix uv_fs_event_stop() assert (Ben Noordhuis)

* unix: remove redundant include in unix.h (

* doc: mark SmartOS as Tier 3 support (

* doc: fix broken links for netbsd's sysctl manpage (

* misc: adjust stalebot deadline (

* test: remove `dns-server.c` as it is not used anywhere (

* build: fix non-cmake android builds (

* doc: replace pyuv with uvloop (

* asan: fix some tests (

* build: add experimental TSAN configuration (

* pipe: remove useless assertion (

* bsd: destroy mutex in uv__process_title_cleanup() (

* build: add windows build to CI (

* win,fs: fix error code in uv_fs_read() and uv_fs_write() ( Sen)

* build: add macos-latest to ci matrix (

* udp: fix &/&& typo in macro condition (

* build: install cmake package module (Petr Menšík)

* win: fix build for mingw32 (

* build: fix build failures with MinGW new headers (erw7)

* build: fix win build with cmake versions before v3.14 (

* unix: support aarch64 in uv_cpu_info() (

* linux: work around CIFS EPERM bug (

* sunos: Oracle Developer Studio support (

* Revert "sunos: Oracle Developer Studio support (

* sunos: Oracle Developer Studio support (

* stream: permit read after seeing EOF (

* thread: initialize uv_thread_self for all threads (

* kqueue: ignore write-end closed notifications (

* macos: fix the cfdata length in uv__get_cpu_speed ( Bache)

* unix,win: add uv_ip_name to get name from sockaddr (

* win,test: fix a few typos (AJ Heller)

* zos: use destructor for uv__threadpool_cleanup() ( Zhang)

* linux: use MemAvailable instead of MemFree (

* freebsd: call dlerror() only if necessary (

* bsd,windows,zos: fix udp disconnect EINVAL (
2022-01-04 09:18:00 -05:00
deal
a865f78124
bsd,windows,zos: fix udp disconnect EINVAL (#3350)
Fixes: https://github.com/libuv/libuv/issues/3344
2022-01-03 11:31:29 +01:00
Jameson Nash
64742416e0
freebsd: call dlerror() only if necessary (#3388)
Similar to the dlopen() codepath.

Refs: https://github.com/JuliaLang/julia/pull/40392
Refs: https://github.com/JuliaLang/julia/issues/39582
2022-01-03 11:25:45 +01:00
Andrey Hohutkin
beb64b0a88
linux: use MemAvailable instead of MemFree (#3351)
Fixes: https://github.com/nodejs/node/issues/23892
2022-01-03 11:24:19 +01:00
Wayne Zhang
0a47e4c771
zos: use destructor for uv__threadpool_cleanup() (#3376)
On z/OS, instead of calling the uv__threadpool_cleanup() function from
inside uv_library_shutdown(), the destructor attribute must be used;
otherwise, tests will fail with exit code 1 and no output. Additionally,
post() does not need to be called when the destructor attribute is used.

Also adds uv__os390_cleanup() function to clean System V message queue
on z/OS.

Co-authored-by: Igor Todorovski <itodorov@ca.ibm.com>
Co-authored-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
2021-12-03 10:04:44 +01:00
AJ Heller
4075298df2
win,test: fix a few typos
PR-URL: https://github.com/libuv/libuv/pull/3375
2021-11-30 23:22:31 -05:00
Campbell He
c7843ecfbc
unix,win: add uv_ip_name to get name from sockaddr (#3368)
uv_ip_name is a kind of wrapper of uv_ip4_name and uv_ip6_name
which can be used after getaddrinfo to get the IP name directly
from addrinfo.ai_addr.
2021-11-25 10:05:15 +01:00
Jesper Storm Bache
1e7074913e
macos: fix the cfdata length in uv__get_cpu_speed (#3356)
We observed crashes inside CFRelease in uv__get_cpu_speed on the new
Mac Book Pro (arm) hardware. The problem is that the stack got
clobbered. On the new mac hardware the returned length is 8.

For the 4 byte case, a temp variable is used to avoid having to add
endian-sensitive offsets.

Fixes: https://github.com/libuv/libuv/issues/3355
2021-11-24 19:50:52 -05:00
Jameson Nash
abfc4f0b15
kqueue: ignore write-end closed notifications (#3277)
The combination EVFILT_WRITE+EV_EOF is valid and indicates that the
reader has disconnected (called `shutdown(SHUT_RD)`). Probably very rare
in practice, but this seems more correct.

Issue noticed (for UV_DISCONNECT clients of uv_poll), while doing
research for https://github.com/libuv/libuv/pull/3250.
2021-11-24 19:37:02 -05:00
Jameson Nash
40bf9a89eb
thread: initialize uv_thread_self for all threads (#3357)
In particular, previously the main thread would have an id of NULL,
which was then not valid to use with any other API that expected a
uv_thread_t handle.
2021-11-24 19:34:57 -05:00