Skip to content

uvio's read_stream() may not trigger task scheduling #9605

Closed
@klutzy

Description

@klutzy

std::rt::uv::uvio::read_stream() calls StreamWatcher::read_start() with on_read callback containing scheduler.resume_blocked_task_immediately(task_cell.take());.

However, in some bad cases, read_start() does not call on_read, thus the task hangs.

Here is excerpt from libuv/src/win/stream.c:

int uv_read_start(uv_stream_t* handle, uv_alloc_cb alloc_cb,
    uv_read_cb read_cb) {
...
  if (handle->flags & UV_HANDLE_READING) {
    fprintf(stderr, "UV_HANDLE_READING. return UV_EALREADY");
    return UV_EALREADY;
  }

  if (!(handle->flags & UV_HANDLE_READABLE)) {
    fprintf(stderr, "!UV_HANDLE_READABLE. return UV_ENOTCONN");
    return UV_ENOTCONN;
  }

...
      err = uv_tcp_read_start((uv_tcp_t*)handle, alloc_cb, read_cb);
...
}

This blocks #8811's read_eof_twice_ip4() and read_eof_twice_ip6() tests on win32: second stream.read() triggers UV_HANDLE_READABLE condition.
The problem does not occur on unix since there is no check equivalent to UV_HANDLE_READABLE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions