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

Incorrect check for file descriptor validity can cause files to fail to open #67

Open
amaurea opened this issue Dec 14, 2018 · 0 comments

Comments

@amaurea
Copy link

amaurea commented Dec 14, 2018

Line 191 in file.c checks whether a file descriptor is valid, like this:

if (! dir->fd || dir->fd == -1)

This treats a file descriptor of 0 as a failure, but 0 is a fully valid file descriptor that can be returned from open. This caused mysterious problems opening files for me yesterday, so it's not just a theoretical issue. Usually a file descriptor of 0 is not encountered because it's taken up by standard input, so I guess that's why this has gone unnoticed, but on the supercomputer I ran this on (with intel compiler 19.0 and intel-mpi 2019.1), 0 was only reserved (presumably for standard input) on the root mpi task. For the others 0 was unallocated, and ended up being returned by open in zzip, causing file opens to fail for all mpi tasks except the root task.

Changing the line to

if(dir->fd == -1)

fixed the problem. I did not notice any side effects.

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

1 participant