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

io_error: "too many open files" on Mac #10442

Closed
volodg opened this issue Nov 12, 2013 · 4 comments
Closed

io_error: "too many open files" on Mac #10442

volodg opened this issue Nov 12, 2013 · 4 comments

Comments

@volodg
Copy link

volodg commented Nov 12, 2013

Source:

use std::rand;

fn main() {

    for _ in range(0u, 1000u) {

        do spawn {

            while (true) {

                println!("{}", rand::random::<uint>());
            }
        }
    }
}

Compilation and run: rustc main.rs; ./main

Result:

task '<unnamed>' failed at 'Unhandled condition: io_error: rt::io::IoError{kind: OtherIoError, desc: "too many open files", detail: None}
@alexcrichton
Copy link
Member

This is an unfortunate consequence of using libuv right now. All println requests go through libuv, which requires a handle to stdout. Whenever we get a libuv handle, we must eventually close it, but this will close the underlying file descriptor of the handle. To get around this, we dup the stdout file descriptor, causing you to reach the file descriptor limit fairly quickly on osx.

That being said, libuv recently had a patch (joyent/libuv@359d6678) to not close stdio file descriptors on unix. Sadly they're still closed on windows, so we haven't been able to fix this just yet. We can special-case unix/windows right now, but I'd almost rather just wait until joyent/libuv#991 is fixed.

Thanks for the bug report though!

@hatahet
Copy link
Contributor

hatahet commented Nov 19, 2013

@alexcrichton Are there plans to move away from libuv?

@alexcrichton
Copy link
Member

No, but there are many plans to optimize our usage of libuv!

@alexcrichton
Copy link
Member

This was closed by #10804 now that we're no longer calling dup on all the stdio file descriptors on linux/max. We're still required to do it on windows, but that's a libuv limitation. Next time libuv is updated, that's something to watch for.

flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 10, 2023
Downgrade let_underscore_untyped to restriction

From reading rust-lang#6842 I am not convinced of the cost/benefit of this lint even as a pedantic lint.

It sounds like the primary motivation was to catch cases of `fn() -> Result` being changed to `async fn() -> Result`. If the original Result was ignored by a `let _`, then the compiler wouldn't guide you to add `.await`. **However, this situation is caught in a more specific way by [let_underscore_future](https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_future) which was introduced _after_ the original suggestion (rust-lang#9760).**

In rust-lang#10410 it was mentioned twice that a <kbd>restriction</kbd> lint might be more appropriate for let_underscore_untyped.

changelog: Moved [`let_underscore_untyped`] to restriction
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

3 participants