-
Notifications
You must be signed in to change notification settings - Fork 72
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
Potential bug when a source is closed while its poller is waiting #51
Comments
(Maybe related to the behavior I mentioned in smol-rs/async-io#64 (comment)?) |
I finally got my mitts on a Windows PC, and it looks like it hangs there too. |
I've tested it and it looks like, for most of our backends, this isn't an issue. It just keeps polling if an FD is dropped while polling. This may be an issue for the |
for |
As of #123 this is explicitly undefined behavior. |
Take this code:
On Linux (
Linux 5.15.0-53-generic #59-Ubuntu
) this code simply hangs forever. I'm not sure how Windows reacts; I do not have a Windows machine accessible to me right now for testing, and Wine falls victim to a separate bug that I will be filing shortly (Edit: #52).I realized that, once a file descriptor is registered into
polling
, there's no mechanism preventing that file descriptor from being deleted. While this is not an issue in most use cases (e.g.async-io
), it may lead to buggy or even undefined behavior. The man page forepoll_wait
says:The man page for
select
says (emphasis mine):I'm not entirely sure how
kqueue
orwepoll
react in this case. In any case, I think that we need to decide:rustix
, which uses a system where theEpoll
(in this case) either takes ownership of the source or borrows it for the duration of the polling process.rustix
's pattern doesn't translate that well toasync-io
's use case, since thePoller
is'static
, ruling out borrowing, and theAsync
still needs access to the source forget_ref()
and other functions. Perhaps there could be some kind of reference counting system, or a unique token.The text was updated successfully, but these errors were encountered: