unikraft / lib-newlib

Unikraft port of newlib, a C standard library
Other
5 stars 23 forks source link

include/fcntl.h: mismatch between `O_NONBLOCK` and `FNONBLOCK` causes a blocking socket for `redis` on `AArch64` #20

Closed mariasfiraiala closed 1 year ago

mariasfiraiala commented 2 years ago

Describe the bug

redis doesn't accept requests when run on AArch64.

There seems to be a mismatch between O_NONBLOCK and FNONBLOCK. FNONBLOCK shoud be an alias for O_NONBLOCK used by vfscore to create a nonblocking socket. However, redis makes use of the O_NONBLOCK flag, and even though the value for these 2 flags should be the same, it isn't.

That is because on AArch64 the O_NONBLOCK flag is redefined in include/fcntl.h, while, FNONBLOCK isn't.

The result is a blocking socket, which makes it impossible for redis to accept further requests.

Steps to reproduce

Build and run redis using newlib support on AArch64.

Download this executable and run it using this command:

$./redis-cli -h 172.44.0.2 -p 6379

Expected behavior

redis to be responding to requests:

$./redis-cli -h 172.44.0.2 -p 6379
172.44.0.2:6379> PING
PONG
172.44.0.2:6379> exit

Which architectures were you using or does this bug affect?

AArch64

Which platforms were you using or does this bug affect?

KVM

eduardvintila commented 2 years ago

Can confirm this issue is present on my end, as well. This seems to affect all apps which are using newlibc and the internal library vfscore to manage blocking/non-blocking I/O.