[PATCH] D30010: Improve the robustness of mmap
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 15:05:18 PST 2017
zturner created this revision.
Herald added subscribers: srhines, danalbert.
When we mmap a file, we don't take into consideration whether the file is on a remote share. mmaping such a file is problematic because if the network share goes away -- which can happen for reasons outside of the user's control -- anything trying to read from that file will have undefined behavior.
LLDB already has logic to check whether a file is local or remote, but it was not implemented on Windows.
Also, `mmap` on newer versions of OSX have some additional flags which LLDB requires and which I see no reason to ever NOT include even for general usage, so the low level call to `mmap` is udpated to use those flags when available.
Note that I do not have **any** non-Windows machine to test on, so I'm including a lot of people from various platforms here to look over this:
Getting the `statvfs` / `statfs` distiction correct was tricky, but hopefully I got this correct. FWIU,
NetBSD: `statfs` does not exist! Must use `statvfs` for everything. Reference <http://netbsd.gw.com/cgi-bin/man-cgi?statvfs+2+NetBSD-current>
FreeBSD: `statvfs::f_flag` does not contain `MNT_LOCAL`. Must use `statfs`. Reference <https://www.freebsd.org/cgi/man.cgi?query=statvfs>
OpenBSD: Both functions exist, but documentation does not specify whether the flags differ between the two.
Since FreeBSD cannot use `statvfs` to check for `MNT_LOCAL`, I'm adjusting the conditional in `Path.inc` so that `FreeBSD` and `OpenBSD` follow the same codepath. Nothing was broken before, it's only now that we need to use `f_flag & MNT_LOCAL` that FreeBSD requires a change to use `statfs` instead.
https://reviews.llvm.org/D30010
Files:
llvm/include/llvm/Support/FileSystem.h
llvm/lib/Support/MemoryBuffer.cpp
llvm/lib/Support/Unix/Path.inc
llvm/lib/Support/Windows/Path.inc
llvm/unittests/Support/Path.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30010.88614.patch
Type: text/x-patch
Size: 8544 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170215/cce3a3fd/attachment.bin>
More information about the llvm-commits
mailing list