| Commit message (Collapse) | Author | Age |
... | |
|
|
|
| |
Get parent process ID using NtQueryInformationProcess, it's faster than
using CreateToolhelp32Snapshot.
|
|
|
|
|
|
| |
Use GetProcessAffinityMask() to estimate the available parallelism.
Before this commit, it simply used the number of available CPUs.
Fixes: https://github.com/libuv/libuv/issues/4520
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
In #4470, I accidentally copied the bug from unix, where calling
uv_stream_set_blocking can cause the whole process to hang on a read.
However, unlike unix, where libuv attempts to set the O_NONBLOCK flag in
uv_pipe_open (as long as the handle never gets passed to uv_spawn), the
NT kernel is not capable of enabling OVERLAPPED operation later (but
fortunately, it also cannot disable it later too).
This implementation might be good to copy to unix (using FIONREAD) to
address the same bug that happens there if the user has called uv_spawn
or uv_stream_set_non_blocking on this handle in the past.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Establishes a user event for kqueue to eliminate the overhead
of the pipe and the system call read(2) per wakeup event.
---------
Signed-off-by: Andy Pan <i@andypan.me>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refactor / cleanup arithmetic for unix -> win filetime conversion
in order to avoid multiplication overflow.
Fixes:
```
src/win/fs.c:106:48: runtime error: signed integer overflow: 1702781567 * 10 cannot be represented in type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/fs.c:106:48 in
```
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
|
|
|
|
|
|
|
| |
The SQPOLL io_uring instance wasn't providing consistent behaviour to
users depending on kernel versions, load shape, ... creating issues
difficult to track and fix. Don't use this ring by default but allow
enabling it by calling `uv_loop_configure()` with
`UV_LOOP_ENABLE_IO_URING_SQPOLL`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
```
|
|
|
|
|
|
|
| |
The Event should be reset before reading the value, or libuv might miss
an update that occurred too rapidly after the previously one.
Refs: https://github.com/libuv/libuv/pull/2381
Refs: https://github.com/libuv/libuv/discussions/4485
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes a race condition if multiple threads are reading from the
same NamedPipe, which could previously lead to a deadlock situation. We
also substantially improve performance now also, since the PeekFile
call is unnecessary overhead with this change. This API was added in
Windows Vista.
Related to #4467, though doesn't address any of the problems there. I
believe that someone could now implement uv__pipe_try_write using
this same code pattern however.
|
|
|
|
|
|
|
|
|
|
| |
Windows added a new API for file information, which doesn't have to
open the file thus greatly improving performance:
https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getfileinformationbyname
The stat functions are already covered by tests, so no test was added
here. I considered comparing the result of old and new code, but that
would require exposing internal fs functions, and we would be testing
Windows functionality, not libuv.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Register the eventfd with EPOLLET to enable edge-triggered notification
where we're able to eliminate the overhead of reading the eventfd via
system call on each wakeup event.
When the eventfd counter reaches the maximum value of the unsigned 64-bit,
which may not happen for the entire lifetime of the process, we rewind the
counter and retry.
This optimization saves one system call on each event-loop wakeup,
eliminating the overhead of read(2) as well as the extra latency
for each epoll wakeup.
|
|
|
| |
Which was broken both in `windows` and `macos`.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
Implements posix delete for files and dirs, with fallback to the old
method if not supported (e.g. Fat32 or Win8).
Fixes: #3839
|
|
|
|
|
|
|
| |
This was incorrectly mapped originally, which makes for confusing error
messages about an EPIPE if a program happens to (unwisely) set PIPE_WAIT
on the handle. It is unclear to me if libuv should try to handle this in
some meaningful way, and very unclear what that way would look like, but
at least expose this to the caller with the correct errno translation.
|
|
|
|
|
|
|
| |
Disable sendfile() on iOS with arm64 architecture
to avoid crashes caused by throwing SIGSYS signal.
Fixes: #3187
|
| |
|
|
|
|
|
| |
- ptsname() needs _XOPEN_SOURCE >= 500
- setenv needs _POSIX_C_SOURCE >= 200112
- setgroups needs grp.h
|
|
|
|
| |
Remove the unused `req` parameter from the uv__req_register and
uv__req_unregister macros.
|
|
|
|
|
|
|
| |
CreateProcessW() in uv_spawn() on Windows will fail with
ERROR_BAD_EXE_FORMAT if attempting to run a file that is not
an executable.
Refs: https://github.com/libuv/libuv/issues/2348
|
|
|
|
|
|
| |
---------
Signed-off-by: Andy Pan <i@andypan.me>
|
|
|
| |
Signed-off-by: Andy Pan <i@andypan.me>
|
|
|
|
|
|
| |
On IBM AIX (and PASE for IBM i), use st_timespec_t
when _XOPEN_SOURCE>=700 and _ALL_SOURCE is defined.
Signed-off-by: Jeffrey H. Johnson <trnsz@pobox.com>
|
| |
|
|
|
|
|
| |
---------
Signed-off-by: Andy Pan <i@andypan.me>
|
|
|
|
|
|
| |
---------
Signed-off-by: Andy Pan <i@andypan.me>
|
|
|
|
|
| |
---------
Signed-off-by: Andy Pan <i@andypan.me>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
| |
Windows 7 is no longer supported.
|
|
|
|
|
|
|
|
|
|
| |
mach_continuous_time is available since macOS 10.12, but our minimum
version is 11, so no need for a workaround.
Also, prefer that to `clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW)` which
the documentation suggests
(https://developer.apple.com/documentation/driverkit/3438077-mach_continuous_time)
since the latter calls mach_timebase_info every time, unnecessarify: https://github.com/apple-open-source/macos/blob/49dcc07a40d19fa97384033a8398dae5d00d11a1/Libc/gen/clock_gettime.c#L107
|
|
|
| |
Our platform-specific headers provide a dedicated indicator.
|
|
|
|
|
|
| |
Make it less likely for the thread-local error value to get
clobbered between performing the operation and checking the result.
Refs: https://github.com/libuv/libuv/issues/4338
|
|
|
|
|
|
|
| |
The file descriptor leak in the inner path was pointed out by @theanarkh
and I subsequently spotted another one in the outer loop. Rewrite the
function to process all control messages.
Refs: https://github.com/libuv/libuv/pull/4357
|
|
|
|
|
|
|
| |
Benchmarking shows that sendmsg() is persistently around 1% faster for
single datagrams, and that kind of stands to reason because there is
less setup overhead, and the kernel has to copy in less data.
Fixes: https://github.com/libuv/libuv/issues/4320
|
|
|
|
|
|
|
| |
* win: simplify uv_once implementation
InitOnceExecuteOnce is available in Windows >= Vista.
Ref: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initonceexecuteonce
|
|
|
|
| |
Closes: https://github.com/libuv/libuv/pull/4350
Closes: https://github.com/libuv/libuv/issues/3487
|
|
|
|
|
|
|
| |
Perform EPOLL_CTL_DEL immediately instead of going through
io_uring's submit queue, otherwise the file descriptor may
be closed by the time the kernel starts the operation.
Fixes: https://github.com/libuv/libuv/issues/4323
|
|
|
|
|
|
|
| |
I removed the fallback code back in October but it prevents Node.js
from upgrading libuv in their v20.x release line because they support
systems older than we do. Bring back a dlsym-based fallback path.
Fixes: https://github.com/libuv/libuv/issues/4332
|
|
|
|
|
|
| |
Remove it since it can cause stack overflows. Use heap allocation
instead.
Fixes: https://github.com/libuv/libuv/issues/4348
|
|
|
|
| |
- The filename of the executable may contain both spaces and parentheses
- Use uv__slurp instead of open/read/close
|
| |
|
|
|
|
|
|
|
| |
Make sure we allocate the memory with uv__malloc so it's in turn freed
with uv__free.
Fixes: https://github.com/libuv/libuv/issues/4329
|
|
|
|
|
|
|
|
| |
It might happen that only using `WaitForSingleObject()` with timeout 0
could return WAIT_TIMEOUT as the process might not have been signaled
yet. To improve things, first use `GetExitCodeProcess()` and check
that `status` is not `STILL_ACTIVE`. Then, to cover for the case that the exit
code was actually `STILL_ACTIVE` use `WaitForSingleObject()`. This could
still be prone to the race condition but only for that case.
|
|
|
|
|
|
|
| |
According to the documentation for Cygwin, the penultimate field
of /proc/pid/stat corresponds to the RSS, so the method is basically
the same as in the Linux version. The only difference is that getpagesize()
will return wincap.allocation_granularity(), but in this mapping, RSS is
calculated using wincap.page_size(), which can be accessed by sysinfo.mem_unit.
|
|
|
|
|
|
|
|
|
| |
Issue:
1. uv__io_poll calls uv__udp_io with revents == POLLIN + POLLOUT
2. uv__udp_io calls your recv_cb
3. you close the handle in callback
4. uv__udp_io calls uv__udp_sendmsg
5. uv__udp_sendmsg calls uv__io_feed
6. kaboom!
|
|
|
|
|
|
|
|
|
| |
uv_available_parallelism does not handle container cpu limit
set by systems like Docker or Kubernetes. This patch fixes
this limitation by comparing the amount of available cpus
returned by syscall with the quota of cpus available defined
in the cgroup.
Fixes: https://github.com/libuv/libuv/issues/4146
|