When the user closes an uv_poll_t handle, there may still be an
outstanding AFD_POLL request. Libuv can't cancel this AFD_POLL request
directly, so it has to submit another which makes the the previous
poll request return.
Libuv completely forgets about the "canceling" AFD_POLL request, but
at some point in time it may complete and store its result somewhere in
memory.
Without this patch the result of the canceling poll request is written
somewhere on the stack, which sometimes causes stack corruption. This
patch ensures that the result is written to some static scratch space
where it can do no harm.
PR-URL: https://github.com/libuv/libuv/pull/49
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Marc Schlaich <marc.schlaich@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The offending patch doesn't completely fix the issue, it just trades
stack corruption for heap corruption which is less likely.
In addition there is a much simpler solution for this problem.
This reverts commit cd894521dd.
PR-URL: https://github.com/libuv/libuv/pull/49
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Marc Schlaich <marc.schlaich@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Changes since version 1.0.1:
* linux: fix sigmask size arg in epoll_pwait() call (Ben Noordhuis)
* linux: handle O_NONBLOCK != SOCK_NONBLOCK case (Helge Deller)
* doc: fix spelling (Joey Geralnik)
* unix, windows: fix typos in comments (Joey Geralnik)
* test: canonicalize test runner path (Ben Noordhuis)
* test: fix compilation warnings (Saúl Ibarra Corretgé)
* test: skip tty test if detected width and height are 0 (Saúl Ibarra
Corretgé)
* doc: update README with IRC channel (Saúl Ibarra Corretgé)
* Revert "unix: use cfmakeraw() for setting raw TTY mode" (Ben
Noordhuis)
* doc: document how to get result of uv_fs_mkdtemp (Tim Caswell)
* unix: add flag for blocking SIGPROF during poll (Ben Noordhuis)
* unix, windows: add uv_loop_configure() function (Ben Noordhuis)
* win: keep a reference to AFD_POLL_INFO in cancel poll (Marc Schlaich)
* test: raise fd limit for OSX select test (Saúl Ibarra Corretgé)
* unix: remove overzealous assert in uv_read_stop (Saúl Ibarra Corretgé)
* unix: reset the reading flag when a stream gets EOF (Saúl Ibarra
Corretgé)
* unix: stop reading if an error is produced (Saúl Ibarra Corretgé)
* cleanup: remove all dead assignments (Maciej Małecki)
* linux: return early if we have no interfaces (Maciej Małecki)
* cleanup: remove a dead increment (Maciej Małecki)
As pointed out by clang-analyzer.
PR-URL: https://github.com/libuv/libuv/pull/13
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This was pointed out as possible undefined allocation of 0 bytes by
clang-analyzer. `malloc` of 0 bytes can return either `NULL` or a
valid pointer which can't be dereferenced. On systems which return
`NULL`, we would consider it a `malloc` error and return an `ENOMEM` to
the caller.
PR-URL: https://github.com/libuv/libuv/pull/13
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
As pointed out by clang-analyzer.
PR-URL: https://github.com/libuv/libuv/pull/13
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This aligns the behavior with Windows, where users don't need to
call `uv_read_stop` or `uv_close` if they get an error in the read
callback.
PR-URL: https://github.com/libuv/libuv/pull/47
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Add a per-event loop flag for blocking SIGPROF signals when polling for
events.
The motivation for this addition is to reduce the number of wakeups and
subsequent clock_gettime() system calls when using a sampling profiler.
On Linux, this switches from epoll_wait() to epoll_pwait() when enabled.
Other platforms bracket the poll syscall with pthread_sigmask() calls.
Refs strongloop/strong-agent#3 and strongloop-internal/scrum-cs#37.
PR-URL: https://github.com/libuv/libuv/pull/15
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This reverts commit 0f25560c8a.
This change was introduced to make it possible to use the TTY for binary
I/O but unfortunately it breaks libuv users that depend on the OPOST and
ONLCR flags, like node.js.
There is no point in adding those flags after the call to cfmakeraw()
because that would once again make the TTY unsuitable for binary I/O.
Let's revert it for now and revisit it again later.
Fixeslibuv/libuv#32, reverts joyent/libuv#1567.
PR-URL: https://github.com/libuv/libuv/pull/33
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This happens in certain build environments such as Jenkins if
some tweaking is not performed in the host system.
PR-URL: https://github.com/libuv/libuv/pull/22
The get_currentexe test requires a canonicalized argv[0] to check
against. Before this commit, it failed when argv[0] contained symbolic
links.
Fixeslibuv/libuv#18.
Fix various typos and spelling mistakes in comments.
Does not affect any code, just changes comments.
PR-URL: https://github.com/libuv/libuv/pull/17
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Fix various typos and spelling mistakes in the documentation
PR-URL: https://github.com/libuv/libuv/pull/17
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Make sure we initialize it after the handle was removed from the pending
queue so that QUEUE_REMOVE doesn't do an invalid write when the process
is closed.
Valgrind output:
==4362== Invalid write of size 8
==4362== at 0x407DB8: uv__process_close (process.c:515)
==4362== by 0x404F94: uv_close (core.c:138)
==4362== by 0x4037C5: main (invalid_write.c:33)
==4362== Address 0xffeffc820 is not stack'd, malloc'd or (recently) free'd
==4362==
==4362== Invalid write of size 8
==4362== at 0x407DC3: uv__process_close (process.c:515)
==4362== by 0x404F94: uv_close (core.c:138)
==4362== by 0x4037C5: main (invalid_write.c:33)
==4362== Address 0xffeffc828 is not stack'd, malloc'd or (recently) free'd
Refs: joyent/libuv/issues/1584
linux-syscalls.h assumes that on all Linux platforms the value
of O_NONBLOCK is the same as SOCK_NONBLOCK.
This commit fixes it, as it is at least not true for hppa, and
resolves#1442.
Signed-off-by: Luca Bruno <lucab@debian.org>
sizeof(sigset_t) = 128 whereas the kernel expects 8, the size of a long.
It made the system call fail with EINVAL when a non-NULL sigset was
passed in. Fortunately, it's academic because there is just one call
site and it passes in NULL.
Fixeslibuv/libuv#4.
The existing probes, all two of them, cause a great deal of pain for
people trying to build libuv on Linux because of SystemTap's dtrace(1)
utilitity not understanding the -xnolibs flag.
We could hack around that but it's easier to just remove the probes:
they are largely useless and unused while still needing a lot of
supporting infrastructure. This commit removes 200 lines of code
and configuration.
Refs joyent/libuv#1478.
59658a8de7 changed uv_thread_self()
to return uv_thread_t, but uv_thread_t is a thread's HANDLE while
uv_thread_self() returns the current thread's id.
This means that uv_thread_equal() is also broken, as we are
potentially comparing HANDLES to ids.
Changed uv_thread_self() to return the current thread's creation handle.
Fixed small doc issue.