8000 BUG: Fix ndarray.tofile large file corruption in append mode by potocpav · Pull Request #8335 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix ndarray.tofile large file corruption in append mode #8335

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
Dec 4, 2016
Merged

BUG: Fix ndarray.tofile large file corruption in append mode #8335

merged 1 commit into from
Dec 4, 2016

Conversation

potocpav
Copy link
Contributor
@potocpav potocpav commented Dec 3, 2016

Fixes by using the flag FALLOC_FL_KEEP_SIZE (=1) in the fappend call.

Fixes #8329

@charris
Copy link
Member
charris commented Dec 3, 2016

Works 8000 for me. @juliantaylor Comment?

@@ -46,7 +46,7 @@ npy_fallocate(npy_intp nbytes, FILE * fp)
}
/* btrfs can take a while to allocate making release worthwhile */
NPY_BEGIN_ALLOW_THREADS;
r = fallocate(fileno(fp), 0, npy_ftell(fp), nbytes);
r = fallocate(fileno(fp), 1, npy_ftell(fp), nbytes);
Copy link
Contributor

Choose a reason for hiding this comment

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

should have a comment that this is FALLOC_FL_KEEP_SIZE needed for the case of files opened in append mode

@juliantaylor
Copy link
Contributor

might be a good idea to flush the file descriptor too, in case there might be some unexpected interactions between the call and unwritten data in the descriptor.

@juliantaylor
Copy link
Contributor

a test writing two arrays to an append mode file would also be good, similar to the above test but without the seek.

@potocpav
Copy link
Contributor Author
potocpav commented Dec 4, 2016

@juliantaylor I added a fflush call before the fappend call. Is that what you had in mind?

@juliantaylor
Copy link
Contributor

yes, thank you. Can you still squash the two commits please.

…append file mode

Fixes by using the flag `FALLOC_FL_KEEP_SIZE` (=1) in the `fappend` call.

Fixes #8329
@potocpav
Copy link
Contributor Author
potocpav commented Dec 4, 2016

Sure, done.

@juliantaylor juliantaylor merged commit 6587f66 into numpy:master Dec 4, 2016
@juliantaylor
Copy link
Contributor

thanks

@charris charris changed the title BUG: tofile() creates a corrupt file for large arrays in "ab" mode BUG: Fix ndarray.tofile large file corruption in append mode Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0