facebookexperimental / facebookexperimental/libunifex
Incorrect error handling in io_epoll_context
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 210
- PR merge metrics
- No merged PRs in 30d
Description
The code in io_epoll_context implies that `readv` and `writev` syscalls error codes are returned as different negative values. Instead, they always return -1, and actual error code is returned through `errno` variable. The only reason it currently works (even though it always adds fds to `epoll` even if there's an unrecoverable error, not just `EAGAIN`, never calling `set_error` in `start_io`, and calling `set_error` with `EPERM` in case of ANY error, hiding it) is because it compares return code with `-EPERM`, which turns out to be -1 on Linux, and adds such descriptors to `epoll`. I wonder where the idea of this check comes from, cause adding such descriptor to `epoll` wouldn't fix real `EPERM` error...
Contributor guide
Assessment
This issue has not been assessed yet.