Shared mmap and data consistency upon a crash
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Hello, If 1) I mmap() a file using MAP_SHARED, PROT_READ and PROT_WRITE 2) I write into the returned address space 3) my app crashes prior to reaching munmap() and close() Pseudocode: // mmap file (1) p_m = fopen(..) mptr = mmap(..p_m..) // Modify the file (2) *mptr = 0xBEEF; // Crash here (3) *((int *) 0) = 1; Felix _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... I am currently exploring the possibilites to use mmap to speed up some of my most critical I/O, but am wondering about the reliability of mmap and the durability of changes made to a file this way for one particular edge case: // Memory would have been unmapped and the corresponding file closed here // However, this shall not be reached in this example munmap(); fclose(p_m); Will the data written in 2) actually show up in the file? Does mmap() take care that mapped memory and the file it is mapped to are synced in the event of a crash? This email sent to site_archiver@lists.apple.com
participants (1)
-
Felix Schwarz