-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
file descriptor leak #3711
Comments
If you drop a Ultimately when we use epoll, there's nothing we can do about this. The timeout did not cancel the operation because there is no way to cancel it. Regarding your use of |
@Darksonn So do I have to close the descriptor somehow with some unsafe raw_fd? or maybe something else - rework the code flow somehow? |
I don't think there is really anything we can do here. If you close the fd yourself, you get a double close when you drop the Tokio Maybe we could provide an operation for force closing the fd now even if an operation is in process, but this would be vulnerable to race conditions where you e.g. close it in one thread before the other thread starts its operation on the fd, meaning that it could have been reassigned to some other resource in the meantime. What kind of files are you reading from that block forever? If they are device files that support epoll, consider using |
@Darksonn |
Right, it sounds like you shouldn't be using I know that |
Thanks, will dig into this... |
The remeha device handle was not properly desctructed when there was some in-flight operation on the file. Changed to use the AsyncFd on std::fs::File instead. References: tokio-rs/tokio#3711
Version
tokio-fd-leak v0.1.0 (/home/tokio-fd-leak)
└── tokio v1.5.0
└── tokio-macros v1.1.0 (proc-macro)
Platform
Linux x86_64
Description
Hi!
I think I found an interesting bug in tokio. The problem is that in some circumstances (when the device file is waiting for data) the tokio::timeout for read is not releasing/closing the file descriptor.
I can see that the future timeouts with error, but the descriptor is not closed leading to problems after fd exhaustion
I prepared a minimal sample code to reproduce the problem.
Building/steps to reproduce:
I expected to see this happen: timeout is closing descriptor for /dev/mychar0
Instead, this happened:
the program is running like this:
When you look at open descriptors:
ls -la /proc/`pidof tokio-fd-leak`/fdinfo|wc -l
it is constantly raising until number of 522
Then the problem is that it timeouts even when opening any new descriptors from that time:
The text was updated successfully, but these errors were encountered: