Switch from old-style ASSERT macro to new-style ASSERT_EQ,... macros.
Using new-style macros makes it easier to debug test failures
Fixes: https://github.com/libuv/libuv/issues/2974
Pass the loop to MAKE_VALGRIND_HAPPY() so it's explicit on which loop
needs to be cleaned up. Since it asserts on uv_loop_close(), need to
remove a couple of those that were being done before the call.
Cleanup where loop was assigned, so the entire test either uses loop or
uv_default_loop(). Not both.
Also take care of any reqs that may have been left uncleaned.
It was checking that the destination buffer was big enough to hold
the total capacity of the process title (the total storage of argv)
when instead it should be checking that it's big enough to hold
the _current_ process title, which is normally much shorter.
Fixes: https://github.com/libuv/libuv/issues/2666
PR-URL: https://github.com/libuv/libuv/pull/2668
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
uv_(get|set)_process_title is not implemented on IBMi.
PR-URL: https://github.com/libuv/libuv/pull/2574
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Cygwin and MSYS2 are POSIX layers implemented on top of Windows.
Use our POSIX `poll(2)` implementation of our poll abstraction.
For most other components we already have dedicated sources
implementing them in terms of APIs available on Cygwin or
providing non-implementations of components not supported.
This leaves only three components that need Cygwin-specific
implementations:
* uv_uptime: implement using sysinfo
* uv_resident_set_memory: add a placeholder returning UV_ENOSYS
* uv_cpu_info: add a placeholder returning UV_ENOSYS
Update our test suite to account for features not available
due to Cygwin platform limitations or our placeholders.
PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Use built-in proctitle implementation because there is no such thing as
a process title on zOS.
PR-URL: https://github.com/libuv/libuv/pull/1208
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This patch enables querying and setting the process title on AIX.
libuv takes ownership of the memory for argv and returns a deep copy
of the array and its contents.
It also enables the process_title test case.
The process title can be changed on AIX but is handled differently
to Linux/Mac. Commands like ps read the original argv array passed
to the process instead of the memory at argv[0]. To change the process
title we need to update argv[0] to point at a new string and set
argv[1] to NULL (if it exists). This means the process title
can be set to a string of any length.
PR-URL: https://github.com/libuv/libuv/pull/1187
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
- zos: disable test cases not applicable
- zos: build options
- zos: semaphore implementation
- zos: use compare and swap builtins
- zos: struct rusage not the same as other platforms
- zos: backlog<=0 produces undefined behaviour
Will redefine backlog in the following way
* if backlog == 0, set it to 1
* if backlog < 0, set it to SOMAXCONN
- zos: define IMAXBEL as empty flag and implement uv__tty_make_raw
- zos: use udp multicast operations from aix
- zos: ESC in ebcdic
- zos: use LIBPATH for dynamic linker path
- zos: uv_udp_set_ttl only works for ipv6
- zos: increase pthread stack size by factor of 4
- zos: return ENODEV instead of ENXIO errors for setsockopt
- zos: use uv_cond_init the same way as aix
- test: enable oob test for zos
- zos: return EINVAL for zos error code EOPNOTSUPP
PR-URL: https://github.com/libuv/libuv/pull/937
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit causes uv_get_process_title() to:
- return EINVAL if the buffer is null or size is 0
- return ENOBUFS if the title is too big for the buffer
- null terminate the buffer on success
Fixes: https://github.com/libuv/libuv/issues/315
PR-URL: https://github.com/libuv/libuv/pull/928
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
uv_(get|set)_process_title is not implemented for AIX. See unix/aix.c
PR-URL: https://github.com/libuv/libuv/pull/616
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.
A code snippet like this one:
if (uv_foo(loop) < 0) {
uv_err_t err = uv_last_error(loop);
fprintf(stderr, "%s\n", uv_strerror(err));
}
Should be rewritten like this:
int err = uv_foo(loop);
if (err < 0)
fprintf(stderr, "%s\n", uv_strerror(err));
The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
Disable unit test failing due to missing implementation
of uv_(set|get)_process_title for Sun OS (SmartOS).
Based on discussion with @tjfontaine, such implementation is difficult
if possible at all and it won't be done anytime soon. Thus there is
no point in keeping the failing test around.
Shorten the test string from 40 to 38 characters because the title
length is limited to 39 characters.
Truncation of long titles was introduced intentionally by commit
a0c1d84 (see discussion in joyent/node#5006).
uv_set_process_title() was susceptible to a format string vulnerability:
$ node -e 'process.title = Array(42).join("%s")'
Segmentation fault: 11 (core dumped)
The fix is trivial - call setproctitle("%s", s) instead of setproctitle(s) -
but valgrind complains loudly about reads from and writes to uninitialized
memory in libc. It's not a libuv bug because the test case below triggers the
same warnings:
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
setproctitle("%s", "test");
return 0;
}
That's why this commit replaces setproctitle() with sysctl(KERN_PROC_ARGS).
This commit reapplies commit a9f6f06, which got reverted in 69a6afe. The revert
turned out to be unnecessary.
It's making node.js crash when run as root. Backtrace:
(gdb) bt
#0 0x00007fff856e3ff9 in __findenv ()
#1 0x00007fff856e404c in getenv ()
#2 0x000000010004c850 in loop_init (loop=0x10045a792, flags=8) at ev.c:1707
#3 0x000000010004cb3b in ev_backend [inlined] () at /Users/tjfontaine/Development/node/deps/uv/src/unix/ev/ev.c:2090
#4 0x000000010004cb3b in ev_default_loop (flags=1606417108) at ev.c:2092
#5 0x000000010004e5c6 in uv__loop_init (loop=0x10066e330, default_loop=1) at loop.c:52
#6 0x0000000100044367 in uv_default_loop () at core.c:196
#7 0x0000000100004625 in node::Init (argc=1606417456, argv=0x100b0f490) at node.cc:2761
#8 0x000000010000797d in node::Start (argc=1606417600, argv=0x0) at node.cc:2888
#9 0x0000000100000ca4 in start ()
This reverts commits:
b49d6f7 unix: fix uv_set_process_title()
a9f6f06 unix: fix format string vulnerability in freebsd.c
a87abc7 unix: avoid buffer overflow in proctitle.c
dc97d44 unix: move uv_set_process_title() to proctitle.c
uv_set_process_title() was susceptible to a format string vulnerability:
$ node -e 'process.title = Array(42).join("%s")'
Segmentation fault: 11 (core dumped)
The fix is trivial - call setproctitle("%s", s) instead of setproctitle(s) -
but valgrind complains loudly about reads from and writes to uninitialized
memory in libc. It's not a libuv bug because the test case below triggers the
same warnings:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
setproctitle("%s", "test");
return 0;
}
That's why this commit replaces setproctitle() with sysctl(KERN_PROC_ARGS).