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

Socket leak starting with async-std 1.6.4 #891

Closed
tailhook opened this issue Sep 29, 2020 · 5 comments
Closed

Socket leak starting with async-std 1.6.4 #891

tailhook opened this issue Sep 29, 2020 · 5 comments

Comments

@tailhook
Copy link
Contributor

tailhook commented Sep 29, 2020

This example:

async fn connect() {
    loop {
        match async_std::os::unix::net::UnixStream::connect("./non-existent").await {
            Ok(_) => unreachable!(),
            Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
            Err(e) => panic!("Unexpected error: {}", e),
        }
    }
}

fn main() {
    async_std::task::block_on(connect());
}

Crashes with thread 'main' panicked at 'Unexpected error: Too many open files (os error 24)', examples/test-connect.rs:6:23 while it shouldn't and didn't crash in 1.6.3. The crash means file descriptors are leaking (maybe because of a memory leak, but I didn't investigate further).

This file descriptor leak is still there in 1.6.5 and master as of f09fa42.

@yoshuawuyts
Copy link
Contributor

Oh no; thanks for the report! This may be related to #888, which was tracked back to the changes in the latest async-io. Would you mind filing an issue with the async-io crate as well?

@yoshuawuyts
Copy link
Contributor

yoshuawuyts commented Sep 29, 2020

This may also be related to smol-rs/async-io#31; not sure.

@tailhook
Copy link
Contributor Author

So smol-rs/async-io#31 is fixed and this bug is still there on async-io 1.1.5.

@ghost
Copy link

ghost commented Sep 29, 2020

The bug was introduced when socket2 got replaced with nb-connect, and the bug was in that nb-connect would not auto-close the socket if an error occurred before the end of connect().

I pushed a fix a moment ago in nb-connect v1.0.1. If you do cargo update, the problem should go away.

Thanks for the bug report!

@tailhook
Copy link
Contributor Author

Yes it works. Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants