[WIN32,TTY] "unknown error" when read using a small buffer.

19 views
Skip to first unread message

Renato Maia

unread,
Jul 1, 2021, 8:08:12 PMJul 1
to li...@googlegroups.com
I noticed that libuv v1.x (963ecc82) in Windows 10, the
'uv_read_start' on a 'uv_tty_t' fails when provided with a small
buffer which cannot contain the data being read.

I also noticed that it calls the callbacks many times providing
smaller and smaller portions.

I attached an example that illustrates this scenario.

In the following output we get the "unknown error" for the case where
I provide as much characters as the buffer size (254 characters, plus
2 for the line break)

```
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=256)
libuv_ttyreadpeacemeal.c:51:main(server started!)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
libuv_ttyreadpeacemeal.c:18:on_read(nread=85)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=171)
libuv_ttyreadpeacemeal.c:18:on_read(nread=57)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=114)
libuv_ttyreadpeacemeal.c:18:on_read(nread=38)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=76)
libuv_ttyreadpeacemeal.c:18:on_read(nread=25)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=51)
libuv_ttyreadpeacemeal.c:18:on_read(nread=17)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=34)
libuv_ttyreadpeacemeal.c:18:on_read(nread=11)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=23)
libuv_ttyreadpeacemeal.c:18:on_read(nread=7)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=16)
libuv_ttyreadpeacemeal.c:18:on_read(nread=5)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=11)
libuv_ttyreadpeacemeal.c:18:on_read(nread=3)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=8)
libuv_ttyreadpeacemeal.c:18:on_read(nread=2)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=6)
libuv_ttyreadpeacemeal.c:18:on_read(nread=2)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=4)
libuv_ttyreadpeacemeal.c:18:on_read(nread=1)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=3)
libuv_ttyreadpeacemeal.c:18:on_read(nread=1)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=2)
libuv_ttyreadpeacemeal.c:15:on_read(error=unknown error)
```

However, if I provide fewer characters (251 characters, plus 2 for the
line break), everything goes fine:

```
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=256)
libuv_ttyreadpeacemeal.c:51:main(server started!)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
libuv_ttyreadpeacemeal.c:18:on_read(nread=85)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=171)
libuv_ttyreadpeacemeal.c:18:on_read(nread=57)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=114)
libuv_ttyreadpeacemeal.c:18:on_read(nread=38)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=76)
libuv_ttyreadpeacemeal.c:18:on_read(nread=25)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=51)
libuv_ttyreadpeacemeal.c:18:on_read(nread=17)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=34)
libuv_ttyreadpeacemeal.c:18:on_read(nread=11)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=23)
libuv_ttyreadpeacemeal.c:18:on_read(nread=7)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=16)
libuv_ttyreadpeacemeal.c:18:on_read(nread=5)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=11)
libuv_ttyreadpeacemeal.c:18:on_read(nread=3)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=8)
libuv_ttyreadpeacemeal.c:18:on_read(nread=2)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=6)
libuv_ttyreadpeacemeal.c:18:on_read(nread=2)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=4)
libuv_ttyreadpeacemeal.c:18:on_read(nread=1)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=3)
```

Just for comparison, in Linux the output is (254 characters, plus 1
for the line break):

```
libuv_ttyreadpeacemeal.c:51:main(server started!)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=256)
libuv_ttyreadpeacemeal.c:18:on_read(nread=256)
libuv_ttyreadpeacemeal.c:29:on_alloc(provided_size=0)
libuv_ttyreadpeacemeal.c:15:on_read(error=no buffer space available)
```

Is this expected? Am I doing something wrong?

Thanks in advance.

--
Renato Maia
libuv_ttyreadpeacemeal_c.txt
Reply all
Reply to author
Forward
0 new messages