You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've found a bug with errnos that may be prevalent for multiple system calls. I found this while testing the poll() call in a situation where we should return an errno. In this case it was EINTR which should return -1 and set the errno appropriately to 4.
Here we appropriately return -4 from lind_poll and NaClSysPoll .
But [here](static int nacl_irt_poll_lind (struct pollfd *fds, nfds_t nfds, int timeout)
{
int rv = NACL_SYSCALL (poll) (fds, nfds, timeout);
if (rv < 0)
return -rv;
return rv;
}) when we return to the IRT we negate the return value if its negative.
This ends up incorrectly setting the errno and the return value. poll() thinks were returning a non-error value of 4.
I think most of this code is a remnant of changes even before my time, and may be happening for a number of syscalls. We should comb through this code and do some tests to see what syscalls are affected when returning errors and fix those.
I've found a bug with errnos that may be prevalent for multiple system calls. I found this while testing the poll() call in a situation where we should return an errno. In this case it was EINTR which should return -1 and set the errno appropriately to 4.
Here we appropriately return -4 from lind_poll and NaClSysPoll .
But [here](static int nacl_irt_poll_lind (struct pollfd *fds, nfds_t nfds, int timeout)
{
int rv = NACL_SYSCALL (poll) (fds, nfds, timeout);
if (rv < 0)
return -rv;
return rv;
}) when we return to the IRT we negate the return value if its negative.
Then here in [poll.c](https://github.com/Lind-Project/Lind-GlibC/blob/5f73bc6e9b451a2bcef24f6967ece7fbedc41da2/sysdeps/nacl/poll.c#L10 it negates the errno again.
This ends up incorrectly setting the errno and the return value. poll() thinks were returning a non-error value of 4.
I think most of this code is a remnant of changes even before my time, and may be happening for a number of syscalls. We should comb through this code and do some tests to see what syscalls are affected when returning errors and fix those.
@yizhuoliang @Yaxuan-w can you address this as a project while I'm away?
If you have any questions about how the libc functions work @RusherRG and @kuzeyardabulut should be able to answer most questions.
The text was updated successfully, but these errors were encountered: