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

fix(mmap): pre-allocate temp file before mmapping #50

Merged
merged 2 commits into from
May 19, 2023

Conversation

komar007
Copy link
Contributor

@komar007 komar007 commented May 18, 2023

This avoids SIGBUS on memory write in case the temp file is sparse. Implemented for linux only; other target_os cfg values unchanged.
I am unsure windows and mac are affected by #48 and I cannot verify. If so, perhaps a similar fix is needed.

@komar007 komar007 force-pushed the mmap_sparse_file_fix branch 2 times, most recently from 6ec7811 to 2790c66 Compare May 18, 2023 22:30
@zkat
Copy link
Owner

zkat commented May 18, 2023

looks like that's not in libc? Does this need a feature flag or something?

@komar007 komar007 force-pushed the mmap_sparse_file_fix branch 3 times, most recently from 4e165e3 to f0cb8a4 Compare May 18, 2023 22:47
@komar007
Copy link
Contributor Author

It seems it's in libc only on linux. Plus it's way too late:)

This avoids SIGBUS on memory write in case the temp file is sparse.
Implemented for linux only; other target_os cfg values unchanged.
Cargo.toml Outdated
@@ -16,6 +16,7 @@ digest = "0.10.6"
either = "1.6.1"
futures = "0.3.17"
hex = "0.4.3"
libc = "0.2.144"
Copy link
Owner

Choose a reason for hiding this comment

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

could you make this an optional dependency that goes along with memmap? Since we don't use libc unless the mmap feature is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, done

@zkat zkat linked an issue May 19, 2023 that may be closed by this pull request
@zkat zkat merged commit 1ac1d64 into zkat:main May 19, 2023
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.

cacache-11.5.2 crashes with SIGBUS when disk full and data size <= 512KB
2 participants