Skip to content

Fix double close bugs in test_lseek and test_lseek64 #660

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

Merged
merged 1 commit into from
Jul 9, 2017

Conversation

asomers
Copy link
Member

@asomers asomers commented Jul 8, 2017

std::fs::File closes the underlying file descriptor on Drop, without
checking for errors. test_lseek and test_lseek64 also manually close
the file descriptor. That works for single threaded test runs. But for
multithreaded runs, it causes EBADF errors in other tests. Fix the
tests by consuming the File with into_raw_fd(), so its drop method will
never be called.

@Susurrus
Copy link
Contributor

Susurrus commented Jul 9, 2017

Please squash these commits into one and also in the commit message state that the other fix here was to use read_exact and write_all to make sure the entire buffer was read/written, which wasn't done before.

Then it's GTM.

std::fs::File closes the underlying file descriptor on Drop, without
checking for errors.  test_lseek and test_lseek64 also manually close
the file descriptor.  That works for single threaded test runs.  But for
multithreaded runs, it causes EBADF errors in other tests.  Fix the
tests by consuming the File with into_raw_fd(), so its drop method will
never be called.

Also, fix a potential short read bug in the same tests.
@asomers
Copy link
Member Author

asomers commented Jul 9, 2017

bors r+ susurrus

bors bot added a commit that referenced this pull request Jul 9, 2017
660: Fix double close bugs in test_lseek and test_lseek64 r=asomers

std::fs::File closes the underlying file descriptor on Drop, without
checking for errors.  test_lseek and test_lseek64 also manually close
the file descriptor.  That works for single threaded test runs.  But for
multithreaded runs, it causes EBADF errors in other tests.  Fix the
tests by consuming the File with into_raw_fd(), so its drop method will
never be called.
@bors
Copy link
Contributor

bors bot commented Jul 9, 2017

@bors bors bot merged commit a50b476 into nix-rust:master Jul 9, 2017
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