aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
...
* win: use NtQueryInformationProcess in uv_os_getppid (#4514)Zuohui Yang2024-08-26
| | | | Get parent process ID using NtQueryInformationProcess, it's faster than using CreateToolhelp32Snapshot.
* win: compute parallelism from process cpu affinity (#4521)Ben Noordhuis2024-08-26
| | | | | | 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
* unix,win: remove unused rb-tree macro parameters (#4518)Viacheslav Muravyev2024-08-25
|
* win,pipe: restore fallback handling for blocking pipes (#4511)Jameson Nash2024-08-22
| | | | | | | | | | | | 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.
* win: remove deprecated GetVersionExW call (#4486)Shelley Vohr2024-08-15
|
* kqueue: use EVFILT_USER for async if availableAndy Pan2024-08-13
| | | | | | | | | | | 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>
* linux: support abstract unix socket autobinding (#4499)Ben Noordhuis2024-08-10
| | | | | | | | | | | | | 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
* unix,fs: silence -Wunused-result warning (#4496)Santiago Gimeno2024-08-10
|
* win: fix fs.c ubsan failure (#4491)Matheus Izvekov2024-08-07
| | | | | | | | | | | | 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>
* linux: disable SQPOLL io_uring by default (#4492)Santiago Gimeno2024-08-06
| | | | | | | 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`.
* build: ubsan fixes (#4254)Matheus Izvekov2024-08-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ```
* win,signal: fix data race dispatching SIGWINCH (#4488)Jameson Nash2024-08-05
| | | | | | | 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
* win,pipe: fix race with concurrent readers (#4470)Jameson Nash2024-08-02
| | | | | | | | | | | 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.
* win,fs: use the new Windows fast stat API (#4327)Hüseyin Açacak2024-07-30
| | | | | | | | | | 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.
* linux: eliminate a read on eventfd per wakeup (#4400)Andy Pan2024-07-29
| | | | | | | | | | | | | 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.
* fsevents: detect watched directory removal (#4376)Santiago Gimeno2024-07-30
| | | Which was broken both in `windows` and `macos`.
* win: fix env var in uv_os_homedir and uv_os_tmpdir (#4464)Hüseyin Açacak2024-07-29
| | | | | | | | | | | | 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
* win,fs: use posix delete semantics, if supported (#4318)Ian Butterworth2024-07-29
| | | | | | Implements posix delete for files and dirs, with fallback to the old method if not supported (e.g. Fat32 or Win8). Fixes: #3839
* win,error: remap ERROR_NO_DATA to EAGAIN (#4471)Jameson Nash2024-07-29
| | | | | | | 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.
* darwin: fix crash on iOS(arm64)郑苏波 (Super Zheng)2024-07-25
| | | | | | | Disable sendfile() on iOS with arm64 architecture to avoid crashes caused by throwing SIGSYS signal. Fixes: #3187
* hurd: stub uv_thread_setpriority()Olivier Valentin2024-07-18
|
* hurd: add includes and macro prerequisitesOlivier Valentin2024-07-16
| | | | | - ptsname() needs _XOPEN_SOURCE >= 500 - setenv needs _POSIX_C_SOURCE >= 200112 - setgroups needs grp.h
* unix,win: remove unused req parameter from macros (#4435)Viacheslav Muravyev2024-07-11
| | | | Remove the unused `req` parameter from the uv__req_register and uv__req_unregister macros.
* win: map ERROR_BAD_EXE_FORMAT to UV_EFTYPE (#4445)Hüseyin Açacak2024-07-11
| | | | | | | 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
* tcpkeepalive: distinguish OS versions and use proper time unitsAndy Pan2024-06-27
| | | | | | --------- Signed-off-by: Andy Pan <i@andypan.me>
* unix: support SO_REUSEPORT with load balancing for UDP (#4419)Andy Pan2024-06-20
| | | Signed-off-by: Andy Pan <i@andypan.me>
* aix,ibmi: fix compilation errors in fs_copyfile (#4404)Jeffrey H. Johnson2024-05-30
| | | | | | 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>
* unix: support SO_REUSEPORT with load balancing for TCPAndy Pan2024-05-21
|
* bsd: support pipe2() on *BSD (#4412)Andy Pan2024-05-21
| | | | | --------- Signed-off-by: Andy Pan <i@andypan.me>
* unix: use the presence of SOCK_* instead of OS macros for socketpairAndy Pan2024-05-21
| | | | | | --------- Signed-off-by: Andy Pan <i@andypan.me>
* dragonfly: disable SO_REUSEPORT for UDP socket bindings (#4410)Andy Pan2024-05-20
| | | | | --------- Signed-off-by: Andy Pan <i@andypan.me>
* linux,darwin: make `uv_fs_copyfile` behaves like `cp -r` (#4396)Juan José2024-05-08
| | | | | | | | 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>
* win: remove no longer needed defineSaúl Ibarra Corretgé2024-04-22
| | | Windows 7 is no longer supported.
* darwin: simplify uv_hrtimeSaúl Ibarra Corretgé2024-04-15
| | | | | | | | | | 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
* unix: de-duplicate conditions for using kqueue (#4378)Brad King2024-04-14
| | | Our platform-specific headers provide a dedicated indicator.
* win: robustify uv_os_getenv() error checking (#4339)Ben Noordhuis2024-03-31
| | | | | | 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
* unix: fix fd leaks in SCM_RIGHTS error path (#4358)Ben Noordhuis2024-03-25
| | | | | | | 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
* linux: don't use sendmmsg() for single datagrams (#4366)Ben Noordhuis2024-03-25
| | | | | | | 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 implementationSaúl Ibarra Corretgé2024-03-25
| | | | | | | * 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
* unix,win: error on zero delay tcp keepaliveSaúl Ibarra Corretgé2024-03-22
| | | | Closes: https://github.com/libuv/libuv/pull/4350 Closes: https://github.com/libuv/libuv/issues/3487
* linux: don't delay EPOLL_CTL_DEL operations (#4328)Ben Noordhuis2024-03-21
| | | | | | | 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
* unix: reinstate preadv/pwritev fallback code (#4345)Ben Noordhuis2024-03-20
| | | | | | | 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
* win: remove _alloca usage (#4361)Ben Noordhuis2024-03-20
| | | | | | Remove it since it can cause stack overflows. Use heap allocation instead. Fixes: https://github.com/libuv/libuv/issues/4348
* linux: fix /proc/self/stat executable name parsing (#4353)Farzin Monsef2024-03-14
| | | | - The filename of the executable may contain both spaces and parentheses - Use uv__slurp instead of open/read/close
* sunos: sync tcp keep-alive with other unices (#4337)Andy Pan2024-03-12
|
* unix,fs: fix realpath calls that use the system allocatorSaúl Ibarra Corretgé2024-03-08
| | | | | | | 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
* win: almost fix race detecting ESRCH in uv_kill (#4341)Santiago Gimeno2024-03-05
| | | | | | | | 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.
* cygwin: implement uv_resident_set_memory (#4333)Farzin Monsef2024-03-02
| | | | | | | 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.
* udp,unix: fix sendmsg use-after-free (#4321)Geddy2024-02-28
| | | | | | | | | 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!
* linux: fix uv_available_parallelism using cgroup (#4278)Thomas Walter2024-02-28
| | | | | | | | | 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