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

Fixed syncronization bug with file-backed memory. #84

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

Ex-32
Copy link
Collaborator

@Ex-32 Ex-32 commented Jan 3, 2025

The current code calls munmap() without first invoking msync() on the same region: as explained in msync(2), this is a synchronization bug:

msync() flushes changes made to the in-core copy of a file that was mapped into memory using mmap(2) back to the filesystem. Without use of this call, there is no guarantee that changes are written back before munmap(2) is called.

This PR breaks out arena unmapping into an inline static function that first calls msync() with the MS_SYNC flag which requests a page sync for the mapped region and blocks until synchronization is complete, then unmaps the pages with munmap().

@Ex-32 Ex-32 requested a review from charmoniumQ January 3, 2025 10:31
@charmoniumQ charmoniumQ merged commit 35de6b7 into charmoniumQ:main Jan 3, 2025
1 check passed
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