Skip to content

cargo test occasionally leaves a file descriptor open when exec'ing a binary on Mac #6344

@alecmocatta

Description

@alecmocatta

Problem
cargo test occasionally leaves a file descriptor open when execing a binary.

Steps
The following as a test with harness = false in the Cargo.toml:

use std::path::Path;

fn main() {
    for fd in 3..1024 {
        assert!(!Path::new(&format!("/dev/fd/{}", fd)).exists());
    }
}

sometimes balks on Mac, specifically at fd 6, which if you try to open it with File::open("/dev/fd/6") is most of the time successful but sometimes returns ErrorKind::PermissionDenied aka EPERM.

Notes
Witnessed on nightlies for the last ~4 months.

I see this on travis (at least on macos-10.13-xcode9.4.1) running this test occasionally but haven't observed locally. Will update if/when I have more details; documenting in case anyone else observes in the meantime.

cargo 1.32.0-nightly (241fac0e3 2018-11-09)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions