-
Notifications
You must be signed in to change notification settings - Fork 26
Description
On Mac OS 15.5 (24F74) I have the following C wrappers:
int b_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) {
int ret = epoll_ctl(epfd, op, fd, event);
if (fd == 0) {
fprintf(stderr, "b_epoll_ctl: fd == 0\n");
}
if (op == EPOLL_CTL_ADD) {
fprintf(stderr, "b_epoll_ctl: registered fd == %d\n", event->data.fd);
}
return ret == -1 ? -errno : ret;
}
int b_epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) {
int ret = epoll_wait(epfd, events, maxevents, timeout);
for (int i = 0; i < ret; i++) {
if (events[i].data.fd == 0) {
fprintf(stderr, "b_epoll_wait: fd == 0\n");
}
}
int mask = ret >> (sizeof(int) * 8 - 1);
return (mask & -errno) | (~mask & ret);
}
Then I set up a test where multiple threads create their own Epoll FD and start dealing with sockets.
Sometimes, under massive pressure (around one thousand concurrent instances of openssl s_time ) , the above code does not record any registration for FD 0, but epoll_wait returns 1 and reports FD 0 as closed even if it was never added to the epoll_set
It looks like the issue is triggered if I perform a close() after epoll_ctl DEL, but from another thread
It mostly read 0, but it can happen to read also other "ghost" fd that have never been added.
I ran the test suite, this is the result:
The following tests FAILED:
9 - epoll-test.epoll__event_size (Failed)
53 - epoll-test-interpose.epoll__event_size (Failed)
96 - epoll-test-rdhup-linux-def.epoll__event_size (Failed)
138 - timerfd-test.timerfd__expire_five (Failed)
157 - timerfd-test-interpose.timerfd__expire_five (Failed)
Errors while running CTest