unix: UV_STREAM_READABLE and UV_STREAM_WRITABLE flags incorrectly set #773

vtjnash opened this Issue Apr 9, 2013 · 0 comments


None yet

1 participant


The UV_STREAM_READABLE and UV_STREAM_WRITABLE flags are unconditionally set on all pipes and sockets. However, it seems incorrect to consider tcp server sockets to be either readable or writable. Additionally, pipes (e.g. those created by spawn or tty's) are typically not bidirectional.

This leads to an issue where we can call shutdown on these objects (because they are marked writable), but will never receive the shutdown callback (presumably because they can't flush). It also means we can attempt to write to a server object (e.g. if we forget it isn't a client), and instead get:

Assertion failed: (events == UV__POLLIN), function uv__server_io, file src/unix/stream.c, line 501.

The source lines that cause this behavior are:

int uv_pipe_open(uv_pipe_t* handle, uv_file fd) {
  return uv__stream_open((uv_stream_t*)handle,
                         UV_STREAM_READABLE | UV_STREAM_WRITABLE);


static int uv__bind(uv_tcp_t* tcp,
                    int domain,
                    struct sockaddr* addr,
                    int addrsize) {
  int on;

  if (maybe_new_socket(tcp, domain, UV_STREAM_READABLE|UV_STREAM_WRITABLE))
    return -1;

I think the solution for uv__bind is to change the last argument to 0. For uv_pipe_open, it seems to me that either the ipc argument to uv_pipe_init should be changed to a flags argument indicating how the stream will be used, or that uv_pipe_open needs an additional flags argument with the same properties.

@vtjnash vtjnash referenced this issue in JuliaLang/libuv Apr 9, 2013

test failure on 64-bit Ubuntu 12.04 #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment