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

tests/dd: Do not use the OS provided dd utility on FIFOs #5453

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

n1000
Copy link
Contributor

@n1000 n1000 commented Oct 25, 2023

On *BSD and macOS, the system provided dd utility opens up the output file for both reading and writing. This means that the open/write to the FIFO does not block, and almost instantly completes. The system dd then exits, leaving nothing left to be read by the time the coreutils-rs dd tries to open/read the FIFO.

Avoid this problem by just writing to the FIFO from the test case itself, rather than relying on the system provide dd.

On *BSD and macOS, the system provided dd utility opens up the output
file for both reading and writing. This means that the open/write to the
FIFO does not block, and almost instantly completes. The system dd then
exits, leaving nothing left to be read by the time the coreutils-rs dd
tries to open/read the FIFO.

Avoid this problem by just writing to the FIFO from the test case
itself, rather than relying on the system provide dd.
@n1000
Copy link
Contributor Author

n1000 commented Oct 25, 2023

Reference code on FreeBSD's dd.c where it opens the output file for both reading and writing here.

I could not test this fix on macOS (I tested on FreeBSD), but strongly suspect this will also work on macOS since Apple's dd implementation is doing the same thing (seen here).

One potential issue with my proposed solution is that if the uutils/coreutils dd does not open the pipe at all (due to some catastrophic failure), the test case will hang (since the new write is on the main thread). I saw that this test was implemented using a separate thread to perform the write in the background. If you think that approach would be better here (or had some other approach in mind) please let me know and I can refactor.

Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me! It even cleans up the code!

Re: the hanging issue. I don't see much of a problem there at the moment. I think we'll notice the issue soon enough once the tests start hanging.

Just as word of caution: please be careful reading other implementations. In particular, we cannot read the GNU implementation because of license reasons. The BSD implementations are ok, I think, because they have a more compatible license.

@tertsdiepraam tertsdiepraam merged commit f76522e into uutils:main Oct 25, 2023
45 checks passed
@n1000 n1000 deleted the freebsd_fixes_push_2 branch October 25, 2023 15:07
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

Successfully merging this pull request may close these issues.

2 participants