Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

epoll does not report EPOLLERR events #3816

Closed
RalfJung opened this issue Aug 16, 2024 · 4 comments · Fixed by #3820
Closed

epoll does not report EPOLLERR events #3816

RalfJung opened this issue Aug 16, 2024 · 4 comments · Fixed by #3820
Assignees
Labels
A-files Area: related to files, paths, sockets, file descriptors, or handles C-bug Category: This is a bug.

Comments

@RalfJung
Copy link
Member

RalfJung commented Aug 16, 2024

According to the man page, epoll will always report EPOLLERR events. However, our implementation never reports them. This is a problem as Miri will silently accept the program but run it in an incorrect way. There's no good way to throw a "not supported" error here, so we should implement this event notification.

Cc @tiif

@RalfJung RalfJung added C-bug Category: This is a bug. A-shims Area: This affects the external function shims A-files Area: related to files, paths, sockets, file descriptors, or handles and removed A-shims Area: This affects the external function shims labels Aug 16, 2024
@tiif
Copy link
Contributor

tiif commented Aug 17, 2024

Right now I still haven't understood how to trigger EPOLLERR yet. I will look into this.

This is the description from the man page:

 EPOLLERR
              Error condition happened on the associated file
              descriptor.  This event is also reported for the write end
              of a pipe when the read end has been closed.

              epoll_wait will always report for this event; it is not
              necessary to set it in events when calling epoll_ctl().

It is still unclear to me what will be considered an error condition for socketpair or eventfd.

@rustbot claim

@RalfJung
Copy link
Member Author

It is still unclear to me what will be considered an error condition for socketpair or eventfd.

It seems very plausible that the answer is "nothing". I would have thought closing the FD or the peer FD might do that but that doesn't seem to be the case, right? Those cases are both covered already by existing tests?

In that case I would say the fix is to add the flag to our EpollReadyEvents type, and do the plumbing that would forward such events to userspace. Then we are ready for if/when we have an FD type that emits them.

@tiif
Copy link
Contributor

tiif commented Aug 17, 2024

Actually right now I discovered a test case can trigger EPOLLER, #3820 contains the test case.

But I suspect there should be other test cases that I don't know yet. Would it makes sense to leave this issue up first, wait for bug reports, and fix later?

This bug will be discoverable if the user managed to write a test where our epoll notification differs from real system.

@RalfJung
Copy link
Member Author

Actually right now I discovered a test case can trigger EPOLLER, #3820 contains the test case.

Good catch!

If we know about a case, IMO we should implement it.

@bors bors closed this as completed in 0665f6e Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-files Area: related to files, paths, sockets, file descriptors, or handles C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants