astral-sh / astral-sh/tar-codec
Test extracts_through_deep_ambient_and_created_path in archive-trait reaches file descriptor limits
- Dominant language
- Rust
- Stars
- 9
- Forks
- 3
- Avg merge
- 9m
- Merged PRs (30d)
- 3
Description
Working on a typical Fedora 44 Workstation installation:
```
$ git clone https://github.com/astral-sh/tar-codec.git
$ cd tar-codec/crates/archive-trait
$ cargo test
[…]
test extracts_through_deep_ambient_and_created_path ... FAILED
failures:
---- extracts_through_deep_ambient_and_created_path stdout ----
thread 'extracts_through_deep_ambient_and_created_path' (1495809) panicked at crates/archive-trait/tests/extract.rs:188:10:
deep destination should be removed: Os { code: 24, kind: Uncategorized, message: "Too many open files" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
extracts_through_deep_ambient_and_created_path
test result: FAILED. 8 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s
error: test failed, to rerun pass `--test extract`
```
Running this under `strace` confirms that directories named `segment` are created, and their file descriptors are held open, until the default file-descriptor limit of 1024 is reached.
This happens in
https://github.com/astral-sh/tar-codec/blob/8fac35899b7e14727d61dc6687a4963f70cc28e5/crates/archive-trait/tests/extract.rs#L146-L156
and/or
https://github.com/astral-sh/tar-codec/blob/8fac35899b7e14727d61dc6687a4963f70cc28e5/crates/archive-trait/tests/extract.rs#L165-L169
It wasn’t immediately clear to me how to rewrite these loops to ensure the file descriptors of intermediate directories are closed once they are no longer actively needed, rather than consuming file descriptors proportional to the number of loop iterations.
Contributor guide
Research direction
Start with crates/archive-trait/tests/extract.rs, especially the loops at lines 146-156 and 165-169, then run cargo test --test extract to reproduce extracts_through_deep_ambient_and_created_path. Trace the directory creation and cleanup behavior, and confirm the test passes without holding intermediate directory file descriptors until the limit is reached.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100